Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix program unit tests fail for local machine #1495

Merged
merged 3 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/__tests__/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ describe('With diagnostics warn only', () => {
const testCase = configureTestCase('diagnostics', {
tsJestConfig: {
diagnostics: { warnOnly: true },
noCache: true, // warnings shown only on first compilation
},
})

Expand Down
21 changes: 10 additions & 11 deletions src/compiler/program.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ const baseTsJestConfig = {
}

describe('cache', () => {
const fileName = 'test-cache.ts'
const source = 'console.log("hello")'

beforeAll(() => {
writeFileSync(fileName, source, 'utf8')
})

afterAll(() => {
removeSync(fileName)
})

it('should use the cache with normal program', () => {
const fileName = 'test-cache-program.ts'
const tmp = tempDir('program-compiler')
writeFileSync(fileName, source, 'utf8')
const compiler = makeCompiler({
jestConfig: { cache: true, cacheDirectory: tmp },
tsJestConfig: {
Expand All @@ -47,7 +40,7 @@ describe('cache', () => {
",
"[level:20] visitSourceFileNode(): hoisting
",
"[level:20] diagnoseFn(): computing diagnostics for test-cache.ts using program
"[level:20] diagnoseFn(): computing diagnostics for test-cache-program.ts using program
",
"[level:20] readThrough(): writing caches
",
Expand All @@ -64,10 +57,14 @@ describe('cache', () => {
`)

expect(compiled2).toBe(compiled1)

removeSync(fileName)
})

it('should use the cache with incremental program', () => {
const fileName = 'test-cache-incremental-program.ts'
const tmp = tempDir('incremental-program-compiler')
writeFileSync(fileName, source, 'utf8')
const compiler = makeCompiler({
jestConfig: { cache: true, cacheDirectory: tmp },
tsJestConfig: {
Expand All @@ -88,7 +85,7 @@ describe('cache', () => {
",
"[level:20] visitSourceFileNode(): hoisting
",
"[level:20] diagnoseFn(): computing diagnostics for test-cache.ts using incremental program
"[level:20] diagnoseFn(): computing diagnostics for test-cache-incremental-program.ts using incremental program
",
"[level:20] readThrough(): writing caches
",
Expand All @@ -105,6 +102,8 @@ describe('cache', () => {
`)

expect(compiled2).toBe(compiled1)

removeSync(fileName)
})
})

Expand Down