|
1 | 1 | import { Transformer } from '@jest/transform/build/types' |
2 | 2 | import { Config } from '@jest/types' |
3 | 3 | import { testing } from 'bs-logger' |
| 4 | +import { readFileSync } from 'fs' |
| 5 | +import json5 = require('json5') |
4 | 6 | import { resolve } from 'path' |
5 | 7 | import { Diagnostic, DiagnosticCategory, ModuleKind, ParsedCommandLine, ScriptTarget } from 'typescript' |
6 | 8 | // tslint:disable-next-line:no-duplicate-imports |
@@ -84,6 +86,7 @@ describe('tsJest', () => { |
84 | 86 | expect(get().tsConfig).toEqual(EXPECTED) |
85 | 87 | expect(get({ tsConfig: true }).tsConfig).toEqual(EXPECTED) |
86 | 88 | }) |
| 89 | + |
87 | 90 | it('should be correct for false', () => { |
88 | 91 | expect(get({ tsConfig: false }).tsConfig).toBeUndefined() |
89 | 92 | }) |
@@ -159,35 +162,32 @@ describe('tsJest', () => { |
159 | 162 | }) |
160 | 163 | expect(cs.tsJest.babelConfig!.kind).toEqual('file') |
161 | 164 | expect(cs.tsJest.babelConfig!.value).toContain('.babelrc-foo') |
162 | | - expect(cs.babel?.plugins).toEqual([]) |
163 | | - expect(cs.babel?.presets).toEqual([]) |
| 165 | + expect(cs.babel).toEqual(expect.objectContaining(json5.parse(readFileSync(FILE, 'utf8')))) |
164 | 166 | }) |
165 | 167 |
|
166 | 168 | it('should be correct for given javascript file path', () => { |
167 | | - const FILE = 'src/__mocks__/babel-foo.config.js' |
168 | 169 | const cs = createConfigSet({ |
169 | 170 | tsJestConfig: { |
170 | | - babelConfig: FILE, |
| 171 | + babelConfig: 'src/__mocks__/babel-foo.config.js', |
171 | 172 | }, |
172 | 173 | resolve: null, |
173 | 174 | }) |
174 | 175 | expect(cs.tsJest.babelConfig!.kind).toEqual('file') |
175 | 176 | expect(cs.tsJest.babelConfig!.value).toContain('babel-foo.config.js') |
176 | | - expect(cs.babel?.plugins).toEqual([]) |
177 | | - expect(cs.babel?.presets).toEqual([]) |
| 177 | + expect(cs.babel).toEqual(expect.objectContaining(require('../__mocks__/babel-foo.config'))) |
178 | 178 | }) |
179 | 179 |
|
180 | 180 | it('should be correct for imported javascript file', () => { |
| 181 | + const babelConfig = require('../__mocks__/babel-foo.config') |
181 | 182 | const cs = createConfigSet({ |
182 | 183 | jestConfig: { rootDir: 'src', cwd: 'src' } as any, |
183 | 184 | tsJestConfig: { |
184 | | - babelConfig: require('../__mocks__/babel-foo.config'), |
| 185 | + babelConfig, |
185 | 186 | }, |
186 | 187 | resolve: null, |
187 | 188 | }) |
188 | 189 | expect(cs.tsJest.babelConfig!.kind).toEqual('inline') |
189 | | - expect(cs.babel?.plugins).toEqual([]) |
190 | | - expect(cs.babel?.presets).toEqual([]) |
| 190 | + expect(cs.babel).toEqual(expect.objectContaining(babelConfig)) |
191 | 191 | }) |
192 | 192 |
|
193 | 193 | it('should be correct for inline config', () => { |
|
0 commit comments