diff --git a/src/__tests__/__snapshots__/ng-jest-config.spec.ts.snap b/src/__tests__/__snapshots__/ng-jest-config.spec.ts.snap index 1924636934..6181dfd499 100644 --- a/src/__tests__/__snapshots__/ng-jest-config.spec.ts.snap +++ b/src/__tests__/__snapshots__/ng-jest-config.spec.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`NgJestConfig readTsConfig should return config including Angular compiler config with tsconfig as a string from ts-jest option 1`] = ` +exports[`NgJestConfig _resolveTsConfig should return config including Angular compiler config with tsconfig as a string from ts-jest option 1`] = ` Object { "annotationsAs": "decorators", "declaration": false, @@ -36,7 +36,7 @@ Object { } `; -exports[`NgJestConfig readTsConfig should return config including Angular compiler config with tsconfig as an object from ts-jest option 1`] = ` +exports[`NgJestConfig _resolveTsConfig should return config including Angular compiler config with tsconfig as an object from ts-jest option 1`] = ` Object { "annotationsAs": "decorators", "declaration": false, @@ -60,7 +60,6 @@ Object { "noUnusedParameters": true, "outDir": "", "removeComments": false, - "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -73,7 +72,43 @@ Object { } `; -exports[`NgJestConfig readTsConfig should return config including Angular compiler config without tsconfig defined in ts-jest option 1`] = ` +exports[`NgJestConfig _resolveTsConfig should return config including Angular compiler config with tsconfig as an object from ts-jest option 2`] = ` +Object { + "annotationsAs": "decorators", + "declaration": false, + "enableIvy": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "forceConsistentCasingInFileNames": true, + "importHelpers": true, + "importsNotUsedAsValues": 2, + "inlineSourceMap": false, + "inlineSources": true, + "lib": Array [ + "lib.esnext.d.ts", + "lib.dom.d.ts", + ], + "module": 1, + "noEmit": false, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "outDir": "", + "removeComments": false, + "skipLibCheck": false, + "sourceMap": true, + "strict": true, + "suppressOutputPathCheck": true, + "target": 2, + "types": Array [ + "node", + "jest", + ], +} +`; + +exports[`NgJestConfig _resolveTsConfig should return config including Angular compiler config without tsconfig defined in ts-jest option 1`] = ` Object { "annotationsAs": "decorators", "declaration": false, diff --git a/src/__tests__/ng-jest-config.spec.ts b/src/__tests__/ng-jest-config.spec.ts index 9371524068..611c551982 100644 --- a/src/__tests__/ng-jest-config.spec.ts +++ b/src/__tests__/ng-jest-config.spec.ts @@ -7,7 +7,7 @@ describe('NgJestConfig', () => { const specifiedTsCfgPath = join(__dirname, '..', '..', 'tsconfig.spec.json'); const defaultTsCfgPath = join(__dirname, '..', '..', 'tsconfig.json'); - describe('readTsConfig', () => { + describe('_resolveTsConfig', () => { test('should return config including Angular compiler config with tsconfig as a string from ts-jest option', () => { const ngJestConfig = new NgJestConfig({ testMatch: [], @@ -30,30 +30,36 @@ describe('NgJestConfig', () => { expect(config.options).toMatchSnapshot(); }); - test('should return config including Angular compiler config with tsconfig as an object from ts-jest option', () => { - const ngJestConfig = new NgJestConfig({ - cwd: '.', - testMatch: [], - testRegex: [], - extensionsToTreatAsEsm: [], - globals: { - 'ts-jest': { - tsconfig: { - resolveJsonModule: true, + test.each([ + {}, + { + skipLibCheck: false, + }, + ])( + 'should return config including Angular compiler config with tsconfig as an object from ts-jest option', + (tsconfig) => { + const ngJestConfig = new NgJestConfig({ + cwd: '.', + testMatch: [], + testRegex: [], + extensionsToTreatAsEsm: [], + globals: { + 'ts-jest': { + tsconfig, }, }, - }, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any); - const config = ngJestConfig.parsedTsConfig; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); + const config = ngJestConfig.parsedTsConfig; - delete config.options.basePath; - delete config.options.baseUrl; - expect(config.options.configFilePath).toEqual(normalizeSeparators(defaultTsCfgPath)); - delete config.options.configFilePath; - delete config.options.genDir; - expect(config.options).toMatchSnapshot(); - }); + delete config.options.basePath; + delete config.options.baseUrl; + expect(config.options.configFilePath).toEqual(normalizeSeparators(defaultTsCfgPath)); + delete config.options.configFilePath; + delete config.options.genDir; + expect(config.options).toMatchSnapshot(); + }, + ); test('should return config including Angular compiler config without tsconfig defined in ts-jest option', () => { const ngJestConfig = new NgJestConfig({ diff --git a/src/config/ng-jest-config.ts b/src/config/ng-jest-config.ts index beb0d20217..e2aa1e1cac 100644 --- a/src/config/ng-jest-config.ts +++ b/src/config/ng-jest-config.ts @@ -49,6 +49,7 @@ export class NgJestConfig extends ConfigSet { // Overwrite outDir so we can find generated files next to their .ts origin in compilerHost. outDir: '', suppressOutputPathCheck: true, + skipLibCheck: result.options.skipLibCheck ?? true, // For performance, disable AOT decorator downleveling transformer for applications in the CLI. // The transformer is not needed for VE or Ivy in this plugin since Angular decorators are removed. // While the transformer would make no changes, it would still need to walk each source file AST.