Skip to content

Commit d0f2231

Browse files
committed
fix: some tests
1 parent b327450 commit d0f2231

6 files changed

Lines changed: 10 additions & 32 deletions

File tree

src/cli/config/migrate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Visit https://kulshekhar.github.io/ts-jest/user/config/#jest-preset for more inf
8888

8989
// check the extensions
9090
if (migratedConfig.moduleFileExtensions && migratedConfig.moduleFileExtensions.length && preset) {
91-
const presetValue = dedupSort(preset.value.moduleFileExtensions).join('::')
91+
const presetValue = dedupSort(preset.value.moduleFileExtensions || []).join('::')
9292
const migratedValue = dedupSort(migratedConfig.moduleFileExtensions).join('::')
9393
if (presetValue === migratedValue) {
9494
delete migratedConfig.moduleFileExtensions
@@ -100,7 +100,7 @@ Visit https://kulshekhar.github.io/ts-jest/user/config/#jest-preset for more inf
100100
}
101101
// check the testMatch
102102
else if (migratedConfig.testMatch && migratedConfig.testMatch.length && preset) {
103-
const presetValue = dedupSort(preset.value.testMatch).join('::')
103+
const presetValue = dedupSort(preset.value.testMatch || []).join('::')
104104
const migratedValue = dedupSort(migratedConfig.testMatch).join('::')
105105
if (presetValue === migratedValue) {
106106
delete migratedConfig.testMatch

src/config/config-set.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ describe('versions', () => {
415415
describe('with babel', () => {
416416
it('should return correct version map', () => {
417417
expect(createConfigSet({ tsJestConfig: { babelConfig: {} } }).versions).toEqual({
418-
'@babel/core': '-',
418+
'@babel/core': pkgVersion('@babel/core'),
419419
'babel-jest': pkgVersion('babel-jest'),
420420
jest: pkgVersion('jest'),
421421
'ts-jest': myModule.version,

src/config/create-jest-preset.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ it('should return correct defaults when allowJs is true', () => {
2525
it('should be able to use a base config', () => {
2626
expect(createJestPreset(undefined, {})).toMatchInlineSnapshot(`
2727
Object {
28-
"moduleFileExtensions": Array [
29-
"js",
30-
"json",
31-
"jsx",
32-
"ts",
33-
"tsx",
34-
"node",
35-
],
36-
"testMatch": Array [
37-
"**/__tests__/**/*.[jt]s?(x)",
38-
"**/?(*.)+(spec|test).[tj]s?(x)",
39-
],
4028
"transform": Object {
4129
"^.+\\\\.tsx?$": "ts-jest",
4230
},

src/config/create-jest-preset.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const defaults = jestConfigPkg.defaults
1212

1313
export interface TsJestPresets {
1414
transform: Record<string, string>
15-
testMatch: string[]
16-
moduleFileExtensions: string[]
15+
testMatch: string[] | undefined
16+
moduleFileExtensions: string[] | undefined
1717
}
1818

1919
export interface CreateJestPresetOptions {
@@ -31,7 +31,7 @@ export function createJestPreset(
3131
...from.transform,
3232
[allowJs ? '^.+\\.[tj]sx?$' : '^.+\\.tsx?$']: 'ts-jest',
3333
},
34-
testMatch: from.testMatch || [],
35-
moduleFileExtensions: from.moduleFileExtensions || [],
34+
testMatch: from.testMatch || undefined,
35+
moduleFileExtensions: from.moduleFileExtensions || undefined,
3636
}
3737
}

src/util/importer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ describe('babelCore', () => {
116116
})
117117
it('should fail with correct error message', () => {
118118
expect(() => new Importer().babelCore(fakers.importReason())).toThrowErrorMatchingInlineSnapshot(`
119-
"Unable to load any of these modules: \\"@babel/core\\". [[BECAUSE]]. To fix it:
120-
• for Babel 7: \`npm i -D babel-jest @babel/core\` (or \`yarn add --dev babel-jest @babel/core\`)"
119+
"Unable to load the module \\"@babel/core\\". [[BECAUSE]] To fix it:
120+
↳ install \\"@babel/core\\": \`npm i -D @babel/core\` (or \`yarn add --dev @babel/core\`)"
121121
`)
122122
})
123123
})

src/util/importer.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,7 @@ export class Importer {
4747
}
4848

4949
babelCore(why: ImportReasons): TBabelCore {
50-
// the bridge will choose correct babel version
51-
return this._import(why, 'babel-core', {
52-
alternatives: ['@babel/core'],
53-
installTip: [
54-
// as in https://github.com/facebook/jest/tree/master/packages/babel-jest
55-
{
56-
label: 'for Babel 7',
57-
module: `babel-jest @babel/core`,
58-
},
59-
],
60-
})
50+
return this._import(why, '@babel/core')
6151
}
6252

6353
typescript(why: ImportReasons, which: string): TTypeScript {

0 commit comments

Comments
 (0)