jest-preset-angular 16.2.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "jest-preset-angular",
3
- "version": "16.2.0",
3
+ "version": "17.0.0",
4
4
  "description": "Jest preset configuration for Angular projects",
5
5
  "license": "MIT",
6
6
  "engines": {
7
- "node": "^18.19.1 || ^20.11.1 || >=22.0.0"
7
+ "node": "^20.11.1 || >=22.0.0"
8
8
  },
9
9
  "main": "build/index.js",
10
10
  "typings": "build/index.d.ts",
@@ -48,64 +48,61 @@
48
48
  "prepare": "husky"
49
49
  },
50
50
  "dependencies": {
51
- "@jest/environment-jsdom-abstract": "^30.0.0",
51
+ "@jest/environment-jsdom-abstract": "^30.4.1",
52
52
  "bs-logger": "^0.2.6",
53
- "esbuild-wasm": ">=0.23.0",
54
- "jest-util": "^30.0.0",
55
- "pretty-format": "^30.0.0",
56
- "ts-jest": "^29.4.0"
53
+ "esbuild-wasm": ">=0.28.0",
54
+ "jest-util": "^30.4.1",
55
+ "pretty-format": "^30.4.1",
56
+ "ts-jest": "^29.4.11"
57
57
  },
58
58
  "optionalDependencies": {
59
- "esbuild": ">=0.23.0"
59
+ "esbuild": ">=0.28.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "@angular/compiler-cli": ">=19.0.0 <23.0.0",
63
- "@angular/core": ">=19.0.0 <23.0.0",
64
- "@angular/platform-browser": ">=19.0.0 <23.0.0",
65
- "@angular/platform-browser-dynamic": ">=19.0.0 <23.0.0",
62
+ "@angular/compiler-cli": ">=20.0.0 <23.0.0",
63
+ "@angular/core": ">=20.0.0 <23.0.0",
64
+ "@angular/platform-browser": ">=20.0.0 <23.0.0",
66
65
  "jest": "^30.0.0",
67
66
  "jsdom": ">=26.0.0",
68
- "typescript": ">=5.5"
67
+ "typescript": ">=5.8"
69
68
  },
70
69
  "devDependencies": {
71
- "@angular-devkit/build-angular": "^22.0.0",
72
- "@angular/animations": "^22.0.0",
73
- "@angular/cdk": "^22.0.0",
74
- "@angular/common": "^22.0.0",
75
- "@angular/compiler": "^22.0.0",
76
- "@angular/compiler-cli": "^22.0.0",
77
- "@angular/core": "^22.0.0",
78
- "@angular/forms": "^22.0.0",
79
- "@angular/material": "^22.0.0",
80
- "@angular/platform-browser": "^22.0.0",
81
- "@angular/platform-browser-dynamic": "^22.0.0",
70
+ "@angular-devkit/build-angular": "^22.0.1",
71
+ "@angular/animations": "^22.0.1",
72
+ "@angular/cdk": "^22.0.1",
73
+ "@angular/common": "^22.0.1",
74
+ "@angular/compiler": "^22.0.1",
75
+ "@angular/compiler-cli": "^22.0.1",
76
+ "@angular/core": "^22.0.1",
77
+ "@angular/forms": "^22.0.1",
78
+ "@angular/material": "^22.0.1",
79
+ "@angular/platform-browser": "^22.0.1",
82
80
  "@babel/core": "^7.29.7",
83
81
  "@babel/preset-env": "^7.29.7",
84
- "@commitlint/cli": "^20.5.3",
85
- "@commitlint/config-angular": "^20.5.3",
86
- "@eslint/eslintrc": "^3.3.5",
87
- "@eslint/js": "^9.39.4",
88
- "@jest/environment-jsdom-abstract": "^30.2.0",
89
- "@jest/transform": "^30.3.0",
90
- "@jest/types": "^30.3.0",
82
+ "@commitlint/cli": "^21.0.2",
83
+ "@commitlint/config-angular": "^21.0.2",
84
+ "@eslint/js": "^10.0.1",
85
+ "@jest/environment-jsdom-abstract": "^30.4.1",
86
+ "@jest/transform": "^30.4.1",
87
+ "@jest/types": "^30.4.1",
91
88
  "@types/fs-extra": "^11.0.4",
92
89
  "@types/jest": "^30.0.0",
93
- "@types/node": "^24.12.4",
90
+ "@types/node": "^24.13.2",
94
91
  "@types/semver": "^7.7.1",
95
92
  "@typescript-eslint/eslint-plugin": "^8.48.0",
96
93
  "@typescript-eslint/parser": "^8.48.0",
97
94
  "angular-eslint": "^22.0.0",
98
- "babel-jest": "^30.3.0",
95
+ "babel-jest": "^30.4.1",
99
96
  "chalk": "^4.1.2",
97
+ "conventional-changelog": "^7.2.0",
100
98
  "conventional-changelog-angular": "^8.3.1",
101
- "conventional-changelog-cli": "^5.0.0",
102
99
  "cross-env": "^10.1.0",
103
100
  "esbuild-register": "^3.6.0",
104
- "eslint": "^9.39.4",
101
+ "eslint": "^10.5.0",
105
102
  "eslint-config-prettier": "^10.1.8",
106
103
  "eslint-plugin-import": "^2.32.0",
107
- "eslint-plugin-jest": "^28.14.0",
108
- "eslint-plugin-jsdoc": "^62.9.0",
104
+ "eslint-plugin-jest": "^29.15.2",
105
+ "eslint-plugin-jsdoc": "^63.0.2",
109
106
  "eslint-plugin-prettier": "^5.5.6",
110
107
  "execa": "5.1.1",
111
108
  "fs-extra": "^11.3.5",
@@ -113,20 +110,20 @@
113
110
  "glob": "^13.0.6",
114
111
  "globals": "^17.6.0",
115
112
  "husky": "^9.1.7",
116
- "jest": "^30.3.0",
117
- "jest-environment-jsdom": "^30.1.2",
113
+ "jest": "^30.4.2",
114
+ "jest-environment-jsdom": "^30.4.1",
118
115
  "jsdom": "^26.1.0",
119
116
  "pinst": "^3.0.0",
120
- "prettier": "^3.8.3",
117
+ "prettier": "^3.8.4",
121
118
  "rimraf": "^5.0.10",
122
119
  "rxjs": "^7.8.2",
123
- "semver": "^7.8.2",
120
+ "semver": "^7.8.4",
124
121
  "tslib": "^2.8.1",
125
- "tsx": "^4.21.0",
126
- "type-fest": "^5.6.0",
122
+ "tsx": "^4.22.4",
123
+ "type-fest": "^5.7.0",
127
124
  "typescript": "~6.0.3",
128
125
  "typescript-eslint": "^8.60.1",
129
126
  "zone.js": "~0.16.2"
130
127
  },
131
- "packageManager": "yarn@4.13.0"
128
+ "packageManager": "yarn@4.16.0"
132
129
  }
@@ -1,13 +1,9 @@
1
1
  require('zone.js');
2
2
  require('zone.js/testing');
3
3
 
4
- const { COMPILER_OPTIONS, NgModule, provideZoneChangeDetection, VERSION } = require('@angular/core');
4
+ const { COMPILER_OPTIONS, NgModule, provideZoneChangeDetection } = require('@angular/core');
5
5
  const { getTestBed } = require('@angular/core/testing');
6
6
  const { BrowserTestingModule, platformBrowserTesting } = require('@angular/platform-browser/testing');
7
- const {
8
- BrowserDynamicTestingModule,
9
- platformBrowserDynamicTesting,
10
- } = require('@angular/platform-browser-dynamic/testing');
11
7
 
12
8
  const { polyfillEncoder, resolveTestEnvOptions } = require('../utils');
13
9
 
@@ -15,44 +11,24 @@ const setupZoneTestEnv = (options) => {
15
11
  polyfillEncoder();
16
12
  const resolvedOptions = resolveTestEnvOptions(options) ?? {};
17
13
  const { extraProviders = [], ...testEnvironmentOptions } = resolvedOptions;
18
- if (+VERSION.major >= 21) {
19
- class TestModule {}
20
- NgModule({
21
- providers: [provideZoneChangeDetection()],
22
- })(TestModule);
23
14
 
24
- getTestBed().initTestEnvironment(
25
- [BrowserTestingModule, TestModule],
26
- platformBrowserTesting([
27
- {
28
- provide: COMPILER_OPTIONS,
29
- useValue: {},
30
- multi: true,
31
- },
32
- ...extraProviders,
33
- ]),
34
- testEnvironmentOptions,
35
- );
36
- } else if (+VERSION.major === 20) {
37
- getTestBed().initTestEnvironment(
38
- [BrowserTestingModule],
39
- platformBrowserTesting([
40
- {
41
- provide: COMPILER_OPTIONS,
42
- useValue: {},
43
- multi: true,
44
- },
45
- ...extraProviders,
46
- ]),
47
- testEnvironmentOptions,
48
- );
49
- } else {
50
- getTestBed().initTestEnvironment(
51
- [BrowserDynamicTestingModule],
52
- platformBrowserDynamicTesting(extraProviders),
53
- testEnvironmentOptions,
54
- );
55
- }
15
+ class TestModule {}
16
+ NgModule({
17
+ providers: [provideZoneChangeDetection()],
18
+ })(TestModule);
19
+
20
+ getTestBed().initTestEnvironment(
21
+ [BrowserTestingModule, TestModule],
22
+ platformBrowserTesting([
23
+ {
24
+ provide: COMPILER_OPTIONS,
25
+ useValue: {},
26
+ multi: true,
27
+ },
28
+ ...extraProviders,
29
+ ]),
30
+ testEnvironmentOptions,
31
+ );
56
32
  };
57
33
 
58
34
  module.exports = {
@@ -1,10 +1,9 @@
1
1
  import 'zone.js';
2
2
  import 'zone.js/testing';
3
3
 
4
- import { COMPILER_OPTIONS, NgModule, provideZoneChangeDetection, VERSION } from '@angular/core';
4
+ import { COMPILER_OPTIONS, NgModule, provideZoneChangeDetection } from '@angular/core';
5
5
  import { getTestBed } from '@angular/core/testing';
6
6
  import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';
7
- import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
8
7
 
9
8
  import { polyfillEncoder, resolveTestEnvOptions } from '../utils';
10
9
 
@@ -12,44 +11,24 @@ const setupZoneTestEnv = (options) => {
12
11
  polyfillEncoder();
13
12
  const resolvedOptions = resolveTestEnvOptions(options) ?? {};
14
13
  const { extraProviders = [], ...testEnvironmentOptions } = resolvedOptions;
15
- if (+VERSION.major >= 21) {
16
- class TestModule {}
17
- NgModule({
18
- providers: [provideZoneChangeDetection()],
19
- })(TestModule);
20
14
 
21
- getTestBed().initTestEnvironment(
22
- [BrowserTestingModule, TestModule],
23
- platformBrowserTesting([
24
- {
25
- provide: COMPILER_OPTIONS,
26
- useValue: {},
27
- multi: true,
28
- },
29
- ...extraProviders,
30
- ]),
31
- testEnvironmentOptions,
32
- );
33
- } else if (+VERSION.major === 20) {
34
- getTestBed().initTestEnvironment(
35
- [BrowserTestingModule],
36
- platformBrowserTesting([
37
- {
38
- provide: COMPILER_OPTIONS,
39
- useValue: {},
40
- multi: true,
41
- },
42
- ...extraProviders,
43
- ]),
44
- testEnvironmentOptions,
45
- );
46
- } else {
47
- getTestBed().initTestEnvironment(
48
- [BrowserDynamicTestingModule],
49
- platformBrowserDynamicTesting(extraProviders),
50
- testEnvironmentOptions,
51
- );
52
- }
15
+ class TestModule {}
16
+ NgModule({
17
+ providers: [provideZoneChangeDetection()],
18
+ })(TestModule);
19
+
20
+ getTestBed().initTestEnvironment(
21
+ [BrowserTestingModule, TestModule],
22
+ platformBrowserTesting([
23
+ {
24
+ provide: COMPILER_OPTIONS,
25
+ useValue: {},
26
+ multi: true,
27
+ },
28
+ ...extraProviders,
29
+ ]),
30
+ testEnvironmentOptions,
31
+ );
53
32
  };
54
33
 
55
34
  export { setupZoneTestEnv };
@@ -1,23 +1,14 @@
1
- const angularCore = require('@angular/core');
2
- const { ErrorHandler, NgModule, VERSION, COMPILER_OPTIONS } = require('@angular/core');
1
+ const { ErrorHandler, NgModule, COMPILER_OPTIONS, provideZonelessChangeDetection } = require('@angular/core');
3
2
  const { getTestBed } = require('@angular/core/testing');
4
3
  const { BrowserTestingModule, platformBrowserTesting } = require('@angular/platform-browser/testing');
5
- const {
6
- platformBrowserDynamicTesting,
7
- BrowserDynamicTestingModule,
8
- } = require('@angular/platform-browser-dynamic/testing');
9
4
 
10
5
  const { polyfillEncoder, resolveTestEnvOptions } = require('../utils');
11
- const provideZonelessChangeDetectionFn =
12
- 'provideExperimentalZonelessChangeDetection' in angularCore
13
- ? angularCore.provideExperimentalZonelessChangeDetection
14
- : angularCore.provideZonelessChangeDetection;
15
6
 
16
7
  const provideZonelessConfig = () => {
17
8
  class TestModule {}
18
9
  NgModule({
19
10
  providers: [
20
- VERSION.major < 21 ? provideZonelessChangeDetectionFn() : null,
11
+ provideZonelessChangeDetection(),
21
12
  {
22
13
  provide: ErrorHandler,
23
14
  useValue: {
@@ -26,46 +17,27 @@ const provideZonelessConfig = () => {
26
17
  },
27
18
  },
28
19
  },
29
- ].filter(Boolean),
20
+ ],
30
21
  })(TestModule);
31
22
 
32
23
  return TestModule;
33
24
  };
34
25
 
35
26
  const setupZonelessTestEnv = (options) => {
36
- if (typeof provideZonelessChangeDetectionFn !== 'undefined') {
37
- polyfillEncoder();
38
- const resolvedOptions = resolveTestEnvOptions(options) ?? {};
39
- const { extraProviders = [], ...testEnvironmentOptions } = resolvedOptions;
40
- if (+VERSION.major >= 20) {
41
- getTestBed().initTestEnvironment(
42
- [BrowserTestingModule, provideZonelessConfig()],
43
- platformBrowserTesting([
44
- {
45
- provide: COMPILER_OPTIONS,
46
- useValue: {},
47
- multi: true,
48
- },
49
- ...extraProviders,
50
- ]),
51
- testEnvironmentOptions,
52
- );
53
- } else {
54
- getTestBed().initTestEnvironment(
55
- [BrowserDynamicTestingModule, provideZonelessConfig()],
56
- platformBrowserDynamicTesting(extraProviders),
57
- testEnvironmentOptions,
58
- );
59
- }
60
-
61
- return;
62
- }
63
-
64
- throw Error(
65
- `Cannot find ${
66
- +VERSION.major >= 20 ? 'provideZonelessChangeDetection()' : 'provideExperimentalZonelessChangeDetection()'
67
- } to setup zoneless testing environment. ` +
68
- 'Please use setupZoneTestEnv() from jest-preset-angular/setup-env/setup-zone-env.mjs instead.',
27
+ polyfillEncoder();
28
+ const resolvedOptions = resolveTestEnvOptions(options) ?? {};
29
+ const { extraProviders = [], ...testEnvironmentOptions } = resolvedOptions;
30
+ getTestBed().initTestEnvironment(
31
+ [BrowserTestingModule, provideZonelessConfig()],
32
+ platformBrowserTesting([
33
+ {
34
+ provide: COMPILER_OPTIONS,
35
+ useValue: {},
36
+ multi: true,
37
+ },
38
+ ...extraProviders,
39
+ ]),
40
+ testEnvironmentOptions,
69
41
  );
70
42
  };
71
43
 
@@ -1,22 +1,14 @@
1
- import * as angularCore from '@angular/core';
2
- import { ErrorHandler, NgModule, VERSION, COMPILER_OPTIONS } from '@angular/core';
1
+ import { ErrorHandler, NgModule, COMPILER_OPTIONS, provideZonelessChangeDetection } from '@angular/core';
3
2
  import { getTestBed } from '@angular/core/testing';
4
3
  import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';
5
- import { platformBrowserDynamicTesting, BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
6
4
 
7
5
  import { polyfillEncoder, resolveTestEnvOptions } from '../utils';
8
6
 
9
- const provideZonelessChangeDetectionFn =
10
- 'provideExperimentalZonelessChangeDetection' in angularCore
11
- ? // eslint-disable-next-line import/namespace
12
- angularCore.provideExperimentalZonelessChangeDetection
13
- : angularCore.provideZonelessChangeDetection;
14
-
15
7
  const provideZonelessConfig = () => {
16
8
  class TestModule {}
17
9
  NgModule({
18
10
  providers: [
19
- VERSION.major < 21 ? provideZonelessChangeDetectionFn() : null,
11
+ provideZonelessChangeDetection(),
20
12
  {
21
13
  provide: ErrorHandler,
22
14
  useValue: {
@@ -25,46 +17,27 @@ const provideZonelessConfig = () => {
25
17
  },
26
18
  },
27
19
  },
28
- ].filter(Boolean),
20
+ ],
29
21
  })(TestModule);
30
22
 
31
23
  return TestModule;
32
24
  };
33
25
 
34
26
  const setupZonelessTestEnv = (options) => {
35
- if (typeof provideZonelessChangeDetectionFn !== 'undefined') {
36
- polyfillEncoder();
37
- const resolvedOptions = resolveTestEnvOptions(options) ?? {};
38
- const { extraProviders = [], ...testEnvironmentOptions } = resolvedOptions;
39
- if (+VERSION.major >= 20) {
40
- getTestBed().initTestEnvironment(
41
- [BrowserTestingModule, provideZonelessConfig()],
42
- platformBrowserTesting([
43
- {
44
- provide: COMPILER_OPTIONS,
45
- useValue: {},
46
- multi: true,
47
- },
48
- ...extraProviders,
49
- ]),
50
- testEnvironmentOptions,
51
- );
52
- } else {
53
- getTestBed().initTestEnvironment(
54
- [BrowserDynamicTestingModule, provideZonelessConfig()],
55
- platformBrowserDynamicTesting(extraProviders),
56
- testEnvironmentOptions,
57
- );
58
- }
59
-
60
- return;
61
- }
62
-
63
- throw Error(
64
- `Cannot find ${
65
- +VERSION.major >= 20 ? 'provideZonelessChangeDetection()' : 'provideExperimentalZonelessChangeDetection()'
66
- } to setup zoneless testing environment. ` +
67
- 'Please use setupZoneTestEnv() from jest-preset-angular/setup-env/setup-zone-env.mjs instead.',
27
+ polyfillEncoder();
28
+ const resolvedOptions = resolveTestEnvOptions(options) ?? {};
29
+ const { extraProviders = [], ...testEnvironmentOptions } = resolvedOptions;
30
+ getTestBed().initTestEnvironment(
31
+ [BrowserTestingModule, provideZonelessConfig()],
32
+ platformBrowserTesting([
33
+ {
34
+ provide: COMPILER_OPTIONS,
35
+ useValue: {},
36
+ multi: true,
37
+ },
38
+ ...extraProviders,
39
+ ]),
40
+ testEnvironmentOptions,
68
41
  );
69
42
  };
70
43