Skip to content

Commit

Permalink
test(e2e): group all transformers tests into one singe place (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Sep 19, 2020
1 parent 81fce4c commit 860f102
Show file tree
Hide file tree
Showing 27 changed files with 69 additions and 255 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"baseUrl": ".",
"baseUrl": "./",
"paths": {
"@share/*": ["share/*"]
}
Expand Down
52 changes: 0 additions & 52 deletions e2e/__tests__/__snapshots__/hoisting.test.ts.snap

This file was deleted.

139 changes: 0 additions & 139 deletions e2e/__tests__/__snapshots__/path-mapping.test.ts.snap

This file was deleted.

71 changes: 68 additions & 3 deletions e2e/__tests__/ast-transformers.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,78 @@
import { LogContexts, LogLevels } from 'bs-logger'

import { configureTestCase } from '../__helpers__/test-case'
import { allValidPackageSets } from '../__helpers__/templates'
import { existsSync } from "fs"
import { LogContexts, LogLevels } from 'bs-logger'

describe('AST transformers', () => {
describe('hoisting', () => {
const testCase = configureTestCase('ast-transformers/hoisting', {
jestConfig: {
testEnvironment: 'node',
automock: true,
},
})

testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
})
})
})

describe('path mapping', () => {
const tsJestConfig = {
tsConfig: {
baseUrl: '.',
paths: {
'@share/*': ['share/*']
}
},
astTransformers: {
before: [
'ts-jest/dist/transformers/path-mapping'
],
},
}

describe('without rootDirs', () => {
const testCase = configureTestCase('ast-transformers/path-mapping', {
env: { TS_JEST_LOG: 'ts-jest.log' },
tsJestConfig,
})

testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
})
})
})

describe('with rootDirs', () => {
const testCase = configureTestCase('ast-transformers/path-mapping', {
tsJestConfig: {
...tsJestConfig,
tsConfig: {
...tsJestConfig.tsConfig,
rootDirs: ['./'],
},
},
})

testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
})
})
})
})

describe('with extra options', () => {
const testCase = configureTestCase('ast-transformers/with-extra-options', {
env: { TS_JEST_LOG: 'ts-jest.log' },
noCache: true, // no cache is required when testing against logging otherwise other tests will clear logging
tsJestConfig: {
astTransformers: {
before: [{
Expand All @@ -23,7 +89,6 @@ describe('AST transformers', () => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(existsSync(result.logFilePath)).toBe(true)
const filteredEntries = result.logFileEntries
// keep only debug and above
.filter(m => (m.context[LogContexts.logLevel] || 0) >= LogLevels.debug)
Expand Down
20 changes: 0 additions & 20 deletions e2e/__tests__/hoisting.test.ts

This file was deleted.

40 changes: 0 additions & 40 deletions e2e/__tests__/path-mapping.test.ts

This file was deleted.

0 comments on commit 860f102

Please sign in to comment.