Skip to content

Commit

Permalink
chore(testing): remove depreciation warning
Browse files Browse the repository at this point in the history
jest-preset-angular is now using setupZoneTestEnv
  • Loading branch information
Chabbey committed Nov 25, 2024
1 parent 128778e commit 3a4031e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
29 changes: 18 additions & 11 deletions packages/angular/src/generators/utils/add-jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,25 @@ export async function addJest(
'src',
'test-setup.ts'
);
if (options.strict && tree.exists(setupFile)) {
if (tree.exists(setupFile)) {
const contents = tree.read(setupFile, 'utf-8');
tree.write(
setupFile,
`// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
if (options.strict) {
tree.write(
setupFile,
`${contents}
setupZoneTestEnv(
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
${contents}`
);
errorOnUnknownProperties: true
);
`
);
} else {
tree.write(
setupFile,
`${contents}
setupZoneTestEnv();
`
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('jestProject', () => {
} as JestProjectSchema);
expect(tree.read('libs/lib1/src/test-setup.ts', 'utf-8'))
.toMatchInlineSnapshot(`
"import 'jest-preset-angular/setup-jest';
"import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
"
`);
expect(tree.exists('libs/lib1/jest.config.ts')).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'jest-preset-angular/setup-jest';
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';

0 comments on commit 3a4031e

Please sign in to comment.