Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(config): set skipLibCheck: true if not defined in tsconfig #678

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 39 additions & 4 deletions src/__tests__/__snapshots__/ng-jest-config.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -60,7 +60,6 @@ Object {
"noUnusedParameters": true,
"outDir": "",
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
Expand All @@ -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,
Expand Down
50 changes: 28 additions & 22 deletions src/__tests__/ng-jest-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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({
Expand Down
1 change: 1 addition & 0 deletions src/config/ng-jest-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down