Skip to content

Commit

Permalink
chore: fix program unit tests fail for local machine (#1495)
Browse files Browse the repository at this point in the history
* chore: fix program unit tests fail for local machine

* chore: run diagnostics e2e tests for warning without cache
  • Loading branch information
ahnpnl committed Apr 3, 2020
1 parent 4f3b333 commit 54ba14d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit 54ba14d

Please sign in to comment.