Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions packages/jest/src/default-config.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ const defaultConfigResolver = new DefaultConfigResolver({});
describe('Resolve project default configuration', () => {
it('Should resolve tsconfig relatively to project root', () => {
const config = defaultConfigResolver.resolveForProject(normalize('/some/cool/directory'));
expect(config.transform[defaultConfigResolver.tsJestTransformRegExp]).toEqual([
'jest-preset-angular',
{
stringifyContentPathRegex: '\\.(html|svg)$',
tsconfig: getSystemPath(normalize(`/some/cool/directory/${tsConfigName}`)),
},
]);
const [, transformOptions] = config.transform[defaultConfigResolver.tsJestTransformRegExp];
expect(transformOptions.tsconfig).toEqual(
getSystemPath(normalize(`/some/cool/directory/${tsConfigName}`))
);
});

it('Should resolve path to the tsconfig if "tsConfig" is provided', () => {
const defaultConfigResolver = new DefaultConfigResolver({
tsConfig: './ts-configs/tsconfig.spec.json',
});
const config = defaultConfigResolver.resolveForProject(normalize('/some/cool/project'));
expect(config.transform[defaultConfigResolver.tsJestTransformRegExp]).toEqual([
'jest-preset-angular',
{
stringifyContentPathRegex: '\\.(html|svg)$',
tsconfig: getSystemPath(normalize(`/some/cool/project/ts-configs/tsconfig.spec.json`)),
},
]);
const [, transformOptions] = config.transform[defaultConfigResolver.tsJestTransformRegExp];
expect(transformOptions.tsconfig).toEqual(
getSystemPath(normalize(`/some/cool/project/ts-configs/tsconfig.spec.json`))
);
});

it('Should resolve testMatch pattern relatively to project root', () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/jest/src/default-config.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ export class DefaultConfigResolver {
stringifyContentPathRegex: '\\.(html|svg)$',
// Join with the default `tsConfigName` if the `tsConfig` option is not provided
tsconfig: getTsConfigPath(projectRoot, this.options),
// Default to isolatedModules: true for significantly faster compilation.
// With isolatedModules: false (the previous implicit default), ts-jest uses the
// TypeScript language service to build a full cross-file Program for every test
// file, which becomes extremely slow with Angular 19+ code (signals, new control
// flow, standalone-by-default). Angular 19+ users report 2min → 15min regressions.
// Cross-file type checking is better handled by `tsc --noEmit` or `ng build`.
// Users who need the old behaviour can opt out via their jest.config.ts:
// transform: { '...': ['jest-preset-angular', { isolatedModules: false }] }
// BREAKING CHANGE: targeted for the next major version.
isolatedModules: true,
},
],
},
Expand Down
11 changes: 11 additions & 0 deletions packages/jest/tests/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ module.exports = [
command: 'yarn test:esm --no-cache',
},

// isolatedModules default - behavioral proof
{
id: 'isolated-modules-default',
name: 'jest: isolatedModules:true default works',
purpose:
'Tests pass correctly with isolatedModules:true (default since v21), regression for #1899',
app: 'examples/jest/simple-app',
command:
'node ../../../packages/jest/tests/validate.js --no-cache --expect-suites=2 --expect-tests=4',
},

// CLI passthrough - validated tests
{
id: 'cli-no-cache',
Expand Down
Loading