Skip to content

Commit

Permalink
feat: deprecate setup-jest.js and setup-jest.mjs
Browse files Browse the repository at this point in the history
DEPRECATION

Importing `setup-jest.js`/`setup-jest.mjs` directly is deprecated. The files will be removed in the future.

Please use "setupZoneTestEnv" function instead. Example:

For CJS
```
// setup-jest.ts
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env';

setupZoneTestEnv();
```

For ESM
```
// setup-jest.ts
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/index.mjs';

setupZoneTestEnv();
```
  • Loading branch information
ahnpnl committed Nov 15, 2024
1 parent 21c0238 commit a304036
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions setup-jest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
console.warn(`
Importing "setup-jest.js" directly is deprecated. The file "setup-jest.js" will be removed in the future.
Please use "setupZoneTestEnv" function instead. Example:
// setup-jest.ts
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
setupZoneTestEnv();
`);

require('zone.js');
require('zone.js/testing');
const { TextEncoder, TextDecoder } = require('util');
Expand Down
13 changes: 12 additions & 1 deletion setup-jest.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
console.warn(`
Importing "setup-jest.mjs" directly is deprecated. The file "setup-jest.mjs" will be removed in the future.
Please use "setupZoneTestEnv" function instead. Example:
// setup-jest.ts
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone/index.mjs';
setupZoneTestEnv();
`);

import 'zone.js';
import 'zone.js/testing';
import { TextEncoder, TextDecoder } from 'util';

import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { TextEncoder, TextDecoder } from 'util';

if (typeof globalThis.TextEncoder === 'undefined') {
globalThis.TextEncoder = TextEncoder;
Expand Down

0 comments on commit a304036

Please sign in to comment.