jest-preset-angular 12.1.0 → 12.2.2
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/CHANGELOG.md +33 -0
- package/build/config/global-setup.js +4 -1
- package/build/ng-jest-transformer.js +5 -5
- package/build/ngtsc/reflection/index.js +1 -1
- package/build/ngtsc/reflection/src/host.js +1 -1
- package/build/ngtsc/reflection/src/type_to_value.js +4 -2
- package/build/ngtsc/reflection/src/typescript.js +14 -11
- package/build/ngtsc/reflection/src/util.js +1 -1
- package/build/ngtsc/ts_compatibility/index.js +4 -0
- package/build/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +96 -0
- package/build/presets/index.js +1 -1
- package/build/transformers/downlevel_decorators_transform/downlevel_decorators_transform.js +35 -17
- package/build/transformers/downlevel_decorators_transform/patch_alias_reference_resolution.js +1 -1
- package/build/transformers/replace-resources.js +46 -7
- package/build/utils/ngcc-jest-processor.js +1 -1
- package/esbuild-check.js +8 -0
- package/global-setup.js +1 -1
- package/global-setup.mjs +3 -0
- package/package.json +30 -28
- package/setup-jest.js +24 -11
- package/setup-jest.mjs +27 -13
- package/renovate.json +0 -81
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [12.2.2](https://github.com/thymikee/jest-preset-angular/compare/v12.2.1...v12.2.2) (2022-08-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* include `ts_compatibility/src` when publishing the package ([#1747](https://github.com/thymikee/jest-preset-angular/issues/1747)) ([26f021f](https://github.com/thymikee/jest-preset-angular/commit/26f021f65777661db83692115cb7976c656f1503)), closes [#1743](https://github.com/thymikee/jest-preset-angular/issues/1743)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [12.2.1](https://github.com/thymikee/jest-preset-angular/compare/v12.2.0...v12.2.1) (2022-08-28)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **transformers:** adopt ts 4.8 changes for `replace-resource` ([#1739](https://github.com/thymikee/jest-preset-angular/issues/1739)) ([aea7205](https://github.com/thymikee/jest-preset-angular/commit/aea7205afb9622f2ba09a032505b8dbf5c7105c1)), closes [#1732](https://github.com/thymikee/jest-preset-angular/issues/1732)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [12.2.0](https://github.com/thymikee/jest-preset-angular/compare/v12.1.0...v12.2.0) (2022-07-14)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* add esbuild check to fallback to WASM if needed ([#1619](https://github.com/thymikee/jest-preset-angular/issues/1619)) ([1ece767](https://github.com/thymikee/jest-preset-angular/commit/1ece7674231f5c422df4d2cae12ce3920a7346b9))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* add `global-setup.mjs` to use with Jest ESM mode ([#1661](https://github.com/thymikee/jest-preset-angular/issues/1661)) ([97a0ec8](https://github.com/thymikee/jest-preset-angular/commit/97a0ec8e0303b9c3014fce1ae8bdebbb07c32455))
|
|
30
|
+
* allow configuring options `TestEnvironmentOptions` for setup test env ([#1657](https://github.com/thymikee/jest-preset-angular/issues/1657)) ([a64a4ac](https://github.com/thymikee/jest-preset-angular/commit/a64a4acb1248962e023165eb538e2f4f9954fbaa)), closes [#1656](https://github.com/thymikee/jest-preset-angular/issues/1656)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
1
34
|
# [12.1.0](https://github.com/thymikee/jest-preset-angular/compare/v12.0.1...v12.1.0) (2022-06-03)
|
|
2
35
|
|
|
3
36
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.globalSetup = void 0;
|
|
2
4
|
const tslib_1 = require("tslib");
|
|
3
5
|
const ngcc_jest_processor_1 = require("../utils/ngcc-jest-processor");
|
|
4
|
-
|
|
6
|
+
const globalSetup = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
5
7
|
const ngJestConfig = globalThis.ngJest;
|
|
6
8
|
const tsconfig = ngJestConfig === null || ngJestConfig === void 0 ? void 0 : ngJestConfig.tsconfig;
|
|
7
9
|
if (!(ngJestConfig === null || ngJestConfig === void 0 ? void 0 : ngJestConfig.skipNgcc)) {
|
|
8
10
|
(0, ngcc_jest_processor_1.runNgccJestProcessor)(tsconfig);
|
|
9
11
|
}
|
|
10
12
|
});
|
|
13
|
+
exports.globalSetup = globalSetup;
|
|
@@ -15,7 +15,7 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
15
15
|
super();
|
|
16
16
|
_NgJestTransformer_ngJestLogger.set(this, void 0);
|
|
17
17
|
_NgJestTransformer_esbuildImpl.set(this, void 0);
|
|
18
|
-
|
|
18
|
+
tslib_1.__classPrivateFieldSet(this, _NgJestTransformer_ngJestLogger, (0, bs_logger_1.createLogger)({
|
|
19
19
|
context: {
|
|
20
20
|
[bs_logger_1.LogContexts.package]: 'jest-preset-angular',
|
|
21
21
|
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
|
@@ -25,7 +25,7 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
25
25
|
}), "f");
|
|
26
26
|
if (useNativeEsbuild === undefined) {
|
|
27
27
|
try {
|
|
28
|
-
const esbuildCheckPath = require.resolve('
|
|
28
|
+
const esbuildCheckPath = require.resolve('../esbuild-check.js');
|
|
29
29
|
const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [esbuildCheckPath]);
|
|
30
30
|
useNativeEsbuild = status === 0 && error === undefined;
|
|
31
31
|
}
|
|
@@ -33,7 +33,7 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
33
33
|
useNativeEsbuild = false;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
tslib_1.__classPrivateFieldSet(this, _NgJestTransformer_esbuildImpl, useNativeEsbuild ? require('esbuild') : require('esbuild-wasm'), "f");
|
|
37
37
|
}
|
|
38
38
|
_createConfigSet(config) {
|
|
39
39
|
return new ng_jest_config_1.NgJestConfig(config);
|
|
@@ -44,9 +44,9 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
44
44
|
process(fileContent, filePath, transformOptions) {
|
|
45
45
|
const configSet = super._configsFor(transformOptions);
|
|
46
46
|
if (configSet.processWithEsbuild(filePath)) {
|
|
47
|
-
|
|
47
|
+
tslib_1.__classPrivateFieldGet(this, _NgJestTransformer_ngJestLogger, "f").debug({ filePath }, 'process with esbuild');
|
|
48
48
|
const compilerOpts = configSet.parsedTsConfig.options;
|
|
49
|
-
const { code, map } =
|
|
49
|
+
const { code, map } = tslib_1.__classPrivateFieldGet(this, _NgJestTransformer_esbuildImpl, "f").transformSync(fileContent, {
|
|
50
50
|
loader: 'js',
|
|
51
51
|
format: transformOptions.supportsStaticESM && configSet.useESM ? 'esm' : 'cjs',
|
|
52
52
|
target: compilerOpts.target === configSet.compilerModule.ScriptTarget.ES2015 ? 'es2015' : 'es2016',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNamedVariableDeclaration = exports.isNamedFunctionDeclaration = exports.isNamedClassDeclaration = exports.reflectTypeEntityToDeclaration = exports.reflectObjectLiteral = exports.reflectNameOfDeclaration = exports.reflectIdentifierOfDeclaration = exports.filterToMembersWithDecorator = exports.TypeScriptReflectionHost = exports.typeNodeToValueExpr = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
|
|
5
|
+
tslib_1.__exportStar(require("./src/host"), exports);
|
|
6
6
|
var type_to_value_1 = require("./src/type_to_value");
|
|
7
7
|
Object.defineProperty(exports, "typeNodeToValueExpr", { enumerable: true, get: function () { return type_to_value_1.typeNodeToValueExpr; } });
|
|
8
8
|
var typescript_1 = require("./src/typescript");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isConcreteDeclaration = exports.KnownDeclaration = exports.ClassMemberKind = exports.isDecoratorIdentifier = exports.Decorator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
6
|
exports.Decorator = {
|
|
7
7
|
nodeForError: (decorator) => {
|
|
8
8
|
if (decorator.node !== null) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.typeNodeToValueExpr = exports.typeToValue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
6
|
function typeToValue(typeNode, checker) {
|
|
7
7
|
if (typeNode === null) {
|
|
8
8
|
return missingType();
|
|
@@ -160,7 +160,9 @@ function entityNameToValue(node) {
|
|
|
160
160
|
return left !== null ? typescript_1.default.factory.createPropertyAccessExpression(left, node.right) : null;
|
|
161
161
|
}
|
|
162
162
|
else if (typescript_1.default.isIdentifier(node)) {
|
|
163
|
-
|
|
163
|
+
const clone = typescript_1.default.setOriginalNode(typescript_1.default.factory.createIdentifier(node.text), node);
|
|
164
|
+
clone.parent = node.parent;
|
|
165
|
+
return clone;
|
|
164
166
|
}
|
|
165
167
|
else {
|
|
166
168
|
return null;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reflectObjectLiteral = exports.findMember = exports.filterToMembersWithDecorator = exports.reflectTypeEntityToDeclaration = exports.reflectIdentifierOfDeclaration = exports.reflectNameOfDeclaration = exports.TypeScriptReflectionHost = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
|
+
const ts_compatibility_1 = require("../../ts_compatibility");
|
|
6
7
|
const host_1 = require("./host");
|
|
7
8
|
const type_to_value_1 = require("./type_to_value");
|
|
8
9
|
const util_1 = require("./util");
|
|
@@ -11,11 +12,11 @@ class TypeScriptReflectionHost {
|
|
|
11
12
|
this.checker = checker;
|
|
12
13
|
}
|
|
13
14
|
getDecoratorsOfDeclaration(declaration) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const decorators = (0, ts_compatibility_1.getDecorators)(declaration);
|
|
16
|
+
return decorators !== undefined && decorators.length ?
|
|
17
|
+
decorators.map(decorator => this._reflectDecorator(decorator))
|
|
18
|
+
.filter((dec) => dec !== null) :
|
|
19
|
+
null;
|
|
19
20
|
}
|
|
20
21
|
getMembersOfClass(clazz) {
|
|
21
22
|
const tsClazz = castDeclarationToClassOrDie(clazz);
|
|
@@ -149,8 +150,9 @@ class TypeScriptReflectionHost {
|
|
|
149
150
|
if (typescript_1.default.isVariableDeclaration(decl) && typescript_1.default.isVariableDeclarationList(decl.parent)) {
|
|
150
151
|
topLevel = decl.parent.parent;
|
|
151
152
|
}
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
const modifiers = (0, ts_compatibility_1.getModifiers)(topLevel);
|
|
154
|
+
if (modifiers !== undefined &&
|
|
155
|
+
modifiers.some(modifier => modifier.kind === typescript_1.default.SyntaxKind.ExportKeyword)) {
|
|
154
156
|
return true;
|
|
155
157
|
}
|
|
156
158
|
if (topLevel.parent === undefined || !typescript_1.default.isSourceFile(topLevel.parent)) {
|
|
@@ -310,8 +312,8 @@ class TypeScriptReflectionHost {
|
|
|
310
312
|
return null;
|
|
311
313
|
}
|
|
312
314
|
const decorators = this.getDecoratorsOfDeclaration(node);
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
+
const modifiers = (0, ts_compatibility_1.getModifiers)(node);
|
|
316
|
+
const isStatic = modifiers !== undefined && modifiers.some(mod => mod.kind === typescript_1.default.SyntaxKind.StaticKeyword);
|
|
315
317
|
return {
|
|
316
318
|
node,
|
|
317
319
|
implementation: node,
|
|
@@ -499,7 +501,8 @@ function getFarLeftIdentifier(propertyAccess) {
|
|
|
499
501
|
}
|
|
500
502
|
function getContainingImportDeclaration(node) {
|
|
501
503
|
return typescript_1.default.isImportSpecifier(node) ? node.parent.parent.parent :
|
|
502
|
-
typescript_1.default.isNamespaceImport(node) ? node.parent.parent :
|
|
504
|
+
typescript_1.default.isNamespaceImport(node) ? node.parent.parent :
|
|
505
|
+
null;
|
|
503
506
|
}
|
|
504
507
|
function getExportedName(decl, originalId) {
|
|
505
508
|
return typescript_1.default.isImportSpecifier(decl) ?
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNamedVariableDeclaration = exports.isNamedFunctionDeclaration = exports.isNamedClassDeclaration = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
6
|
function isNamedClassDeclaration(node) {
|
|
7
7
|
return typescript_1.default.isClassDeclaration(node) && isIdentifier(node.name);
|
|
8
8
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.combineModifiers = exports.getModifiers = exports.getDecorators = exports.updateConstructorDeclaration = exports.createSetAccessorDeclaration = exports.updateSetAccessorDeclaration = exports.createGetAccessorDeclaration = exports.updateGetAccessorDeclaration = exports.createPropertyDeclaration = exports.updatePropertyDeclaration = exports.createMethodDeclaration = exports.updateMethodDeclaration = exports.createClassDeclaration = exports.updateClassDeclaration = exports.updateImportDeclaration = exports.updateParameterDeclaration = exports.updateTypeParameterDeclaration = void 0;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
13
|
+
const IS_AFTER_TS_48 = isAfterVersion(4, 8);
|
|
14
|
+
const IS_AFTER_TS_47 = isAfterVersion(4, 7);
|
|
15
|
+
exports.updateTypeParameterDeclaration = IS_AFTER_TS_47 ?
|
|
16
|
+
typescript_1.default.factory.updateTypeParameterDeclaration :
|
|
17
|
+
(node, _modifiers, name, constraint, defaultType) => typescript_1.default.factory.updateTypeParameterDeclaration(node, name, constraint, defaultType);
|
|
18
|
+
exports.updateParameterDeclaration = IS_AFTER_TS_48 ?
|
|
19
|
+
typescript_1.default.factory.updateParameterDeclaration :
|
|
20
|
+
(node, modifiers, dotDotDotToken, name, questionToken, type, initializer) => typescript_1.default.factory.updateParameterDeclaration(node, ...splitModifiers(modifiers), dotDotDotToken, name, questionToken, type, initializer);
|
|
21
|
+
exports.updateImportDeclaration = IS_AFTER_TS_48 ?
|
|
22
|
+
typescript_1.default.factory.updateImportDeclaration :
|
|
23
|
+
(node, modifiers, importClause, moduleSpecifier, assertClause) => typescript_1.default.factory.updateImportDeclaration(node, undefined, modifiers, importClause, moduleSpecifier, assertClause);
|
|
24
|
+
exports.updateClassDeclaration = IS_AFTER_TS_48 ?
|
|
25
|
+
typescript_1.default.factory.updateClassDeclaration :
|
|
26
|
+
(node, combinedModifiers, name, typeParameters, heritageClauses, members) => typescript_1.default.factory.updateClassDeclaration(node, ...splitModifiers(combinedModifiers), name, typeParameters, heritageClauses, members);
|
|
27
|
+
exports.createClassDeclaration = IS_AFTER_TS_48 ?
|
|
28
|
+
typescript_1.default.factory.createClassDeclaration :
|
|
29
|
+
(combinedModifiers, name, typeParameters, heritageClauses, members) => typescript_1.default.factory.createClassDeclaration(...splitModifiers(combinedModifiers), name, typeParameters, heritageClauses, members);
|
|
30
|
+
exports.updateMethodDeclaration = IS_AFTER_TS_48 ?
|
|
31
|
+
typescript_1.default.factory.updateMethodDeclaration :
|
|
32
|
+
(node, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) => typescript_1.default.factory.updateMethodDeclaration(node, ...splitModifiers(modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body);
|
|
33
|
+
exports.createMethodDeclaration = IS_AFTER_TS_48 ?
|
|
34
|
+
typescript_1.default.factory.createMethodDeclaration :
|
|
35
|
+
(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) => typescript_1.default.factory.createMethodDeclaration(...splitModifiers(modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body);
|
|
36
|
+
exports.updatePropertyDeclaration = IS_AFTER_TS_48 ?
|
|
37
|
+
typescript_1.default.factory.updatePropertyDeclaration :
|
|
38
|
+
(node, modifiers, name, questionOrExclamationToken, type, initializer) => typescript_1.default.factory.updatePropertyDeclaration(node, ...splitModifiers(modifiers), name, questionOrExclamationToken, type, initializer);
|
|
39
|
+
exports.createPropertyDeclaration = IS_AFTER_TS_48 ?
|
|
40
|
+
typescript_1.default.factory.createPropertyDeclaration :
|
|
41
|
+
(modifiers, name, questionOrExclamationToken, type, initializer) => typescript_1.default.factory.createPropertyDeclaration(...splitModifiers(modifiers), name, questionOrExclamationToken, type, initializer);
|
|
42
|
+
exports.updateGetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
43
|
+
typescript_1.default.factory.updateGetAccessorDeclaration :
|
|
44
|
+
(node, modifiers, name, parameters, type, body) => typescript_1.default.factory.updateGetAccessorDeclaration(node, ...splitModifiers(modifiers), name, parameters, type, body);
|
|
45
|
+
exports.createGetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
46
|
+
typescript_1.default.factory.createGetAccessorDeclaration :
|
|
47
|
+
(modifiers, name, parameters, type, body) => typescript_1.default.factory.createGetAccessorDeclaration(...splitModifiers(modifiers), name, parameters, type, body);
|
|
48
|
+
exports.updateSetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
49
|
+
typescript_1.default.factory.updateSetAccessorDeclaration :
|
|
50
|
+
(node, modifiers, name, parameters, body) => typescript_1.default.factory.updateSetAccessorDeclaration(node, ...splitModifiers(modifiers), name, parameters, body);
|
|
51
|
+
exports.createSetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
52
|
+
typescript_1.default.factory.createSetAccessorDeclaration :
|
|
53
|
+
(modifiers, name, parameters, body) => typescript_1.default.factory.createSetAccessorDeclaration(...splitModifiers(modifiers), name, parameters, body);
|
|
54
|
+
exports.updateConstructorDeclaration = IS_AFTER_TS_48 ?
|
|
55
|
+
typescript_1.default.factory.updateConstructorDeclaration :
|
|
56
|
+
(node, modifiers, parameters, body) => typescript_1.default.factory.updateConstructorDeclaration(node, undefined, modifiers, parameters, body);
|
|
57
|
+
exports.getDecorators = IS_AFTER_TS_48 ? typescript_1.default.getDecorators : node => node.decorators;
|
|
58
|
+
exports.getModifiers = IS_AFTER_TS_48 ? typescript_1.default.getModifiers : node => node.modifiers;
|
|
59
|
+
function combineModifiers(decorators, modifiers) {
|
|
60
|
+
const hasDecorators = decorators === null || decorators === void 0 ? void 0 : decorators.length;
|
|
61
|
+
const hasModifiers = modifiers === null || modifiers === void 0 ? void 0 : modifiers.length;
|
|
62
|
+
if (hasDecorators && hasModifiers) {
|
|
63
|
+
return [...decorators, ...modifiers];
|
|
64
|
+
}
|
|
65
|
+
if (hasDecorators && !hasModifiers) {
|
|
66
|
+
return decorators;
|
|
67
|
+
}
|
|
68
|
+
if (hasModifiers && !hasDecorators) {
|
|
69
|
+
return modifiers;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
exports.combineModifiers = combineModifiers;
|
|
74
|
+
function splitModifiers(allModifiers) {
|
|
75
|
+
if (!allModifiers) {
|
|
76
|
+
return [undefined, undefined];
|
|
77
|
+
}
|
|
78
|
+
const decorators = [];
|
|
79
|
+
const modifiers = [];
|
|
80
|
+
for (const current of allModifiers) {
|
|
81
|
+
if (typescript_1.default.isDecorator(current)) {
|
|
82
|
+
decorators.push(current);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
modifiers.push(current);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [decorators.length ? decorators : undefined, modifiers.length ? modifiers : undefined];
|
|
89
|
+
}
|
|
90
|
+
function isAfterVersion(targetMajor, targetMinor) {
|
|
91
|
+
const [major, minor] = typescript_1.default.versionMajorMinor.split('.').map(part => parseInt(part));
|
|
92
|
+
if (major < targetMajor) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return major === targetMajor ? minor >= targetMinor : true;
|
|
96
|
+
}
|
package/build/presets/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultEsmPreset = exports.defaultPreset = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const serializers_1 =
|
|
5
|
+
const serializers_1 = tslib_1.__importDefault(require("../serializers"));
|
|
6
6
|
const baseConfig = {
|
|
7
7
|
globals: {
|
|
8
8
|
'ts-jest': {
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDownlevelDecoratorsTransform = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
|
+
const ts_compatibility_1 = require("../../ngtsc/ts_compatibility");
|
|
6
7
|
const patch_alias_reference_resolution_1 = require("./patch_alias_reference_resolution");
|
|
7
8
|
function isAngularDecorator(decorator, isCore) {
|
|
8
9
|
return isCore || (decorator.import !== null && decorator.import.from === '@angular/core');
|
|
@@ -61,7 +62,7 @@ function createCtorParametersClassProperty(diagnostics, entityNameToExpression,
|
|
|
61
62
|
params.push(typescript_1.default.factory.createObjectLiteralExpression(members));
|
|
62
63
|
}
|
|
63
64
|
const initializer = typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), typescript_1.default.factory.createArrayLiteralExpression(params, true));
|
|
64
|
-
const ctorProp =
|
|
65
|
+
const ctorProp = (0, ts_compatibility_1.createPropertyDeclaration)([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], 'ctorParameters', undefined, undefined, initializer);
|
|
65
66
|
if (isClosureCompilerEnabled) {
|
|
66
67
|
typescript_1.default.setSyntheticLeadingComments(ctorProp, [
|
|
67
68
|
{
|
|
@@ -145,7 +146,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
145
146
|
function createDecoratorClassProperty(decoratorList) {
|
|
146
147
|
const modifier = typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword);
|
|
147
148
|
const initializer = typescript_1.default.factory.createArrayLiteralExpression(decoratorList, true);
|
|
148
|
-
const prop =
|
|
149
|
+
const prop = (0, ts_compatibility_1.createPropertyDeclaration)([modifier], 'decorators', undefined, undefined, initializer);
|
|
149
150
|
addJSDocTypeAnnotation(prop, DECORATOR_INVOCATION_JSDOC_TYPE);
|
|
150
151
|
return prop;
|
|
151
152
|
}
|
|
@@ -155,7 +156,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
155
156
|
entries.push(typescript_1.default.factory.createPropertyAssignment(name, typescript_1.default.factory.createArrayLiteralExpression(decorators.map(deco => extractMetadataFromSingleDecorator(deco, diagnostics)))));
|
|
156
157
|
}
|
|
157
158
|
const initializer = typescript_1.default.factory.createObjectLiteralExpression(entries, true);
|
|
158
|
-
const prop =
|
|
159
|
+
const prop = (0, ts_compatibility_1.createPropertyDeclaration)([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], 'propDecorators', undefined, undefined, initializer);
|
|
159
160
|
addJSDocTypeAnnotation(prop, `!Object<string, ${DECORATOR_INVOCATION_JSDOC_TYPE}>`);
|
|
160
161
|
return prop;
|
|
161
162
|
}
|
|
@@ -178,10 +179,10 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
178
179
|
if ((0, patch_alias_reference_resolution_1.isAliasImportDeclaration)(decl)) {
|
|
179
180
|
referencedParameterTypes.add(decl);
|
|
180
181
|
if (decl.name !== undefined) {
|
|
181
|
-
return typescript_1.default.
|
|
182
|
+
return typescript_1.default.setOriginalNode(typescript_1.default.factory.createIdentifier(decl.name.text), decl.name);
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
|
-
return typescript_1.default.
|
|
185
|
+
return typescript_1.default.setOriginalNode(typescript_1.default.factory.createIdentifier(name.text), name);
|
|
185
186
|
}
|
|
186
187
|
function transformClassElement(element) {
|
|
187
188
|
element = typescript_1.default.visitEachChild(element, decoratorDownlevelVisitor, context);
|
|
@@ -209,12 +210,10 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
209
210
|
});
|
|
210
211
|
return [undefined, element, []];
|
|
211
212
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
undefined;
|
|
217
|
-
return [name, mutable, toLower];
|
|
213
|
+
const modifiers = decoratorsToKeep.length ?
|
|
214
|
+
typescript_1.default.setTextRange(typescript_1.default.factory.createNodeArray((0, ts_compatibility_1.combineModifiers)(decoratorsToKeep, (0, ts_compatibility_1.getModifiers)(element))), element.modifiers) :
|
|
215
|
+
(0, ts_compatibility_1.getModifiers)(element);
|
|
216
|
+
return [element.name.text, cloneClassElementWithModifiers(element, modifiers), toLower];
|
|
218
217
|
}
|
|
219
218
|
function transformConstructor(ctor) {
|
|
220
219
|
ctor = typescript_1.default.visitEachChild(ctor, decoratorDownlevelVisitor, context);
|
|
@@ -237,14 +236,13 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
237
236
|
paramInfo.type = param.type;
|
|
238
237
|
}
|
|
239
238
|
parametersInfo.push(paramInfo);
|
|
240
|
-
const newParam =
|
|
239
|
+
const newParam = (0, ts_compatibility_1.updateParameterDeclaration)(param, (0, ts_compatibility_1.combineModifiers)(decoratorsToKeep.length ? decoratorsToKeep : undefined, (0, ts_compatibility_1.getModifiers)(param)), param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
|
|
241
240
|
newParameters.push(newParam);
|
|
242
241
|
}
|
|
243
|
-
const updated =
|
|
242
|
+
const updated = (0, ts_compatibility_1.updateConstructorDeclaration)(ctor, (0, ts_compatibility_1.getModifiers)(ctor), newParameters, ctor.body);
|
|
244
243
|
return [updated, parametersInfo];
|
|
245
244
|
}
|
|
246
245
|
function transformClassDeclaration(classDecl) {
|
|
247
|
-
classDecl = typescript_1.default.getMutableClone(classDecl);
|
|
248
246
|
const newMembers = [];
|
|
249
247
|
const decoratedProperties = new Map();
|
|
250
248
|
let classParameters = null;
|
|
@@ -274,7 +272,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
274
272
|
}
|
|
275
273
|
newMembers.push(typescript_1.default.visitEachChild(member, decoratorDownlevelVisitor, context));
|
|
276
274
|
}
|
|
277
|
-
const decoratorsToKeep = new Set(
|
|
275
|
+
const decoratorsToKeep = new Set((0, ts_compatibility_1.getDecorators)(classDecl));
|
|
278
276
|
const possibleAngularDecorators = host.getDecoratorsOfDeclaration(classDecl) || [];
|
|
279
277
|
let hasAngularDecorator = false;
|
|
280
278
|
const decoratorsToLower = [];
|
|
@@ -301,7 +299,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
301
299
|
newMembers.push(createPropDecoratorsClassProperty(diagnostics, decoratedProperties));
|
|
302
300
|
}
|
|
303
301
|
const members = typescript_1.default.setTextRange(typescript_1.default.factory.createNodeArray(newMembers, classDecl.members.hasTrailingComma), classDecl.members);
|
|
304
|
-
return
|
|
302
|
+
return (0, ts_compatibility_1.createClassDeclaration)((0, ts_compatibility_1.combineModifiers)(decoratorsToKeep.size ? Array.from(decoratorsToKeep) : undefined, (0, ts_compatibility_1.getModifiers)(classDecl)), classDecl.name, classDecl.typeParameters, classDecl.heritageClauses, members);
|
|
305
303
|
}
|
|
306
304
|
function decoratorDownlevelVisitor(node) {
|
|
307
305
|
if (typescript_1.default.isClassDeclaration(node)) {
|
|
@@ -315,3 +313,23 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
315
313
|
};
|
|
316
314
|
}
|
|
317
315
|
exports.getDownlevelDecoratorsTransform = getDownlevelDecoratorsTransform;
|
|
316
|
+
function cloneClassElementWithModifiers(node, modifiers) {
|
|
317
|
+
let clone;
|
|
318
|
+
if (typescript_1.default.isMethodDeclaration(node)) {
|
|
319
|
+
clone = (0, ts_compatibility_1.createMethodDeclaration)(modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
320
|
+
}
|
|
321
|
+
else if (typescript_1.default.isPropertyDeclaration(node)) {
|
|
322
|
+
clone = (0, ts_compatibility_1.createPropertyDeclaration)(modifiers, node.name, node.questionToken, node.type, node.initializer);
|
|
323
|
+
}
|
|
324
|
+
else if (typescript_1.default.isGetAccessor(node)) {
|
|
325
|
+
clone =
|
|
326
|
+
(0, ts_compatibility_1.createGetAccessorDeclaration)(modifiers, node.name, node.parameters, node.type, node.body);
|
|
327
|
+
}
|
|
328
|
+
else if (typescript_1.default.isSetAccessor(node)) {
|
|
329
|
+
clone = (0, ts_compatibility_1.createSetAccessorDeclaration)(modifiers, node.name, node.parameters, node.body);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
throw new Error(`Unsupported decorated member with kind ${typescript_1.default.SyntaxKind[node.kind]}`);
|
|
333
|
+
}
|
|
334
|
+
return typescript_1.default.setOriginalNode(clone, node);
|
|
335
|
+
}
|
package/build/transformers/downlevel_decorators_transform/patch_alias_reference_resolution.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAliasImportDeclaration = exports.loadIsReferencedAliasDeclarationPatch = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
6
|
const patchedReferencedAliasesSymbol = Symbol('patchedReferencedAliases');
|
|
7
7
|
function loadIsReferencedAliasDeclarationPatch(context) {
|
|
8
8
|
if (!isTransformationContextWithEmitResolver(context)) {
|
|
@@ -2,20 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replaceResources = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const typescript_1 =
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
|
+
const isAfterVersion = (targetMajor, targetMinor) => {
|
|
8
|
+
const [major, minor] = typescript_1.default.versionMajorMinor.split('.').map((part) => parseInt(part));
|
|
9
|
+
if (major < targetMajor) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
else if (major > targetMajor) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return minor >= targetMinor;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const IS_TS_48 = isAfterVersion(4, 8);
|
|
7
20
|
const shouldTransform = (fileName) => !fileName.endsWith('.ngfactory.ts') && !fileName.endsWith('.ngstyle.ts');
|
|
8
21
|
function replaceResources({ program }) {
|
|
9
22
|
return (context) => {
|
|
10
23
|
const typeChecker = program.getTypeChecker();
|
|
11
24
|
const resourceImportDeclarations = [];
|
|
12
25
|
const moduleKind = context.getCompilerOptions().module;
|
|
26
|
+
const nodeFactory = context.factory;
|
|
13
27
|
const visitNode = (node) => {
|
|
14
28
|
if (typescript_1.default.isClassDeclaration(node)) {
|
|
15
|
-
|
|
16
|
-
? visitDecorator(context.factory, node, typeChecker, resourceImportDeclarations, moduleKind)
|
|
17
|
-
: node);
|
|
18
|
-
return context.factory.updateClassDeclaration(node, decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
|
|
29
|
+
return visitClassDeclaration(nodeFactory, typeChecker, node, resourceImportDeclarations, moduleKind);
|
|
19
30
|
}
|
|
20
31
|
return typescript_1.default.visitEachChild(node, visitNode, context);
|
|
21
32
|
};
|
|
@@ -25,13 +36,41 @@ function replaceResources({ program }) {
|
|
|
25
36
|
}
|
|
26
37
|
const updatedSourceFile = typescript_1.default.visitNode(sourceFile, visitNode);
|
|
27
38
|
if (resourceImportDeclarations.length) {
|
|
28
|
-
return
|
|
39
|
+
return nodeFactory.updateSourceFile(updatedSourceFile, typescript_1.default.setTextRange(nodeFactory.createNodeArray([...resourceImportDeclarations, ...updatedSourceFile.statements]), updatedSourceFile.statements));
|
|
29
40
|
}
|
|
30
41
|
return updatedSourceFile;
|
|
31
42
|
};
|
|
32
43
|
};
|
|
33
44
|
}
|
|
34
45
|
exports.replaceResources = replaceResources;
|
|
46
|
+
function visitClassDeclaration(nodeFactory, typeChecker, node, resourceImportDeclarations, moduleKind) {
|
|
47
|
+
var _a;
|
|
48
|
+
let decorators;
|
|
49
|
+
let modifiers;
|
|
50
|
+
if (IS_TS_48) {
|
|
51
|
+
(_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.forEach((modifier) => {
|
|
52
|
+
if (typescript_1.default.isDecorator(modifier)) {
|
|
53
|
+
decorators !== null && decorators !== void 0 ? decorators : (decorators = []);
|
|
54
|
+
decorators.push(modifier);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
modifiers = modifiers !== null && modifiers !== void 0 ? modifiers : (modifiers = []);
|
|
58
|
+
modifiers.push(modifier);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
decorators = node.decorators;
|
|
64
|
+
modifiers = node.modifiers;
|
|
65
|
+
}
|
|
66
|
+
if (!decorators || !decorators.length) {
|
|
67
|
+
return node;
|
|
68
|
+
}
|
|
69
|
+
decorators = decorators.map((current) => visitDecorator(nodeFactory, current, typeChecker, resourceImportDeclarations, moduleKind));
|
|
70
|
+
return IS_TS_48
|
|
71
|
+
? nodeFactory.updateClassDeclaration(node, [...decorators, ...(modifiers !== null && modifiers !== void 0 ? modifiers : [])], node.name, node.typeParameters, node.heritageClauses, node.members)
|
|
72
|
+
: nodeFactory.updateClassDeclaration(node, decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
|
|
73
|
+
}
|
|
35
74
|
function visitDecorator(nodeFactory, node, typeChecker, resourceImportDeclarations, moduleKind) {
|
|
36
75
|
if (!isComponentDecorator(node, typeChecker)) {
|
|
37
76
|
return node;
|
|
@@ -104,7 +143,7 @@ function createResourceImport(nodeFactory, url, resourceImportDeclarations, modu
|
|
|
104
143
|
return nodeFactory.createCallExpression(nodeFactory.createIdentifier(constants_1.REQUIRE), [], [urlLiteral]);
|
|
105
144
|
}
|
|
106
145
|
else {
|
|
107
|
-
const importName =
|
|
146
|
+
const importName = nodeFactory.createIdentifier(`__NG_CLI_RESOURCE__${resourceImportDeclarations.length}`);
|
|
108
147
|
const importDeclaration = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, importName, undefined), urlLiteral);
|
|
109
148
|
resourceImportDeclarations.push(importDeclaration);
|
|
110
149
|
return importName;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runNgccJestProcessor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
-
const path_1 =
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const ANGULAR_COMPILER_CLI_PKG_NAME = `@angular${path_1.default.sep}compiler-cli`;
|
|
8
8
|
let ngccPath = '';
|
|
9
9
|
try {
|
package/esbuild-check.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// If the platform does not support the native variant of esbuild, this will crash.
|
|
2
|
+
// This script can then be spawned by the CLI to determine if native usage is supported.
|
|
3
|
+
require('esbuild')
|
|
4
|
+
.formatMessages([], { kind: 'error ' })
|
|
5
|
+
.then(
|
|
6
|
+
() => {},
|
|
7
|
+
() => {}
|
|
8
|
+
);
|
package/global-setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./build/config/global-setup');
|
|
1
|
+
module.exports = require('./build/config/global-setup').globalSetup;
|
package/global-setup.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-preset-angular",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.2",
|
|
4
4
|
"description": "Jest preset configuration for Angular projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -62,46 +62,48 @@
|
|
|
62
62
|
"typescript": ">=4.3"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@angular-devkit/build-angular": "
|
|
66
|
-
"@angular/animations": "^
|
|
67
|
-
"@angular/common": "^
|
|
68
|
-
"@angular/compiler": "^
|
|
69
|
-
"@angular/compiler-cli": "~
|
|
70
|
-
"@angular/core": "
|
|
71
|
-
"@angular/platform-browser": "^
|
|
72
|
-
"@angular/platform-browser-dynamic": "
|
|
73
|
-
"@commitlint/cli": "^17.
|
|
74
|
-
"@commitlint/config-angular": "^17.
|
|
75
|
-
"@jest/transform": "^28.1.
|
|
76
|
-
"@jest/types": "^28.1.
|
|
77
|
-
"@types/jest": "^28.1.
|
|
78
|
-
"@types/node": "^16.11.
|
|
79
|
-
"@types/semver": "^7.3.
|
|
80
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
81
|
-
"@typescript-eslint/parser": "^5.
|
|
65
|
+
"@angular-devkit/build-angular": "^14.2.1",
|
|
66
|
+
"@angular/animations": "^14.2.0",
|
|
67
|
+
"@angular/common": "^14.2.0",
|
|
68
|
+
"@angular/compiler": "^14.2.0",
|
|
69
|
+
"@angular/compiler-cli": "~14.2.0",
|
|
70
|
+
"@angular/core": "^14.2.0",
|
|
71
|
+
"@angular/platform-browser": "^14.2.0",
|
|
72
|
+
"@angular/platform-browser-dynamic": "^14.2.0",
|
|
73
|
+
"@commitlint/cli": "^17.1.1",
|
|
74
|
+
"@commitlint/config-angular": "^17.1.0",
|
|
75
|
+
"@jest/transform": "^28.1.3",
|
|
76
|
+
"@jest/types": "^28.1.3",
|
|
77
|
+
"@types/jest": "^28.1.8",
|
|
78
|
+
"@types/node": "^16.11.56",
|
|
79
|
+
"@types/semver": "^7.3.12",
|
|
80
|
+
"@typescript-eslint/eslint-plugin": "^5.35.1",
|
|
81
|
+
"@typescript-eslint/parser": "^5.35.1",
|
|
82
82
|
"chalk": "^4.1.2",
|
|
83
83
|
"conventional-changelog-cli": "^2.2.2",
|
|
84
84
|
"cross-env": "^7.0.3",
|
|
85
|
-
"eslint": "^8.
|
|
85
|
+
"eslint": "^8.23.0",
|
|
86
86
|
"eslint-config-prettier": "^8.5.0",
|
|
87
87
|
"eslint-plugin-import": "^2.26.0",
|
|
88
|
-
"eslint-plugin-jest": "^26.
|
|
89
|
-
"eslint-plugin-jsdoc": "^39.3.
|
|
88
|
+
"eslint-plugin-jest": "^26.9.0",
|
|
89
|
+
"eslint-plugin-jsdoc": "^39.3.6",
|
|
90
90
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
91
|
-
"eslint-plugin-prettier": "^4.
|
|
91
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
92
92
|
"execa": "5.1.1",
|
|
93
93
|
"fs-extra": "^10.1.0",
|
|
94
94
|
"github-files-fetcher": "^1.6.0",
|
|
95
95
|
"glob": "^8.0.3",
|
|
96
96
|
"husky": "^8.0.1",
|
|
97
|
-
"jest": "^28.1.
|
|
97
|
+
"jest": "^28.1.3",
|
|
98
98
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
99
99
|
"pinst": "^3.0.0",
|
|
100
|
-
"prettier": "^2.
|
|
100
|
+
"prettier": "^2.7.1",
|
|
101
101
|
"rimraf": "^3.0.2",
|
|
102
|
-
"rxjs": "^7.5.
|
|
102
|
+
"rxjs": "^7.5.6",
|
|
103
|
+
"ts-node": "^10.9.1",
|
|
103
104
|
"tslib": "^2.4.0",
|
|
104
|
-
"typescript": "
|
|
105
|
-
"zone.js": "^0.11.
|
|
106
|
-
}
|
|
105
|
+
"typescript": "^4.8.2",
|
|
106
|
+
"zone.js": "^0.11.8"
|
|
107
|
+
},
|
|
108
|
+
"packageManager": "yarn@3.2.3"
|
|
107
109
|
}
|
package/setup-jest.js
CHANGED
|
@@ -5,23 +5,36 @@ const {
|
|
|
5
5
|
platformBrowserDynamicTesting,
|
|
6
6
|
} = require('@angular/platform-browser-dynamic/testing');
|
|
7
7
|
|
|
8
|
-
let
|
|
8
|
+
let testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions ?? Object.create(null);
|
|
9
|
+
|
|
9
10
|
const configuredDestroyAfterEach = globalThis.ngJest?.destroyAfterEach;
|
|
10
11
|
if (configuredDestroyAfterEach) {
|
|
11
12
|
console.warn(
|
|
12
13
|
'Passing destroyAfterEach for configuring the test environment has been deprecated.' +
|
|
13
|
-
' Please pass a `
|
|
14
|
-
' see https://
|
|
14
|
+
' Please pass a `testEnvironmentOptions` object with TestEnvironmentOptions interface instead,' +
|
|
15
|
+
' see https://angular.io/api/core/testing/TestEnvironmentOptions'
|
|
15
16
|
);
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
testEnvironmentOptions = {
|
|
19
|
+
...testEnvironmentOptions,
|
|
20
|
+
teardown: {
|
|
21
|
+
destroyAfterEach: true,
|
|
22
|
+
},
|
|
18
23
|
};
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const configuredTeardown = globalThis.ngJest?.teardown;
|
|
27
|
+
if (configuredTeardown) {
|
|
28
|
+
console.warn(
|
|
29
|
+
'Passing teardown for configuring the test environment has been deprecated.' +
|
|
30
|
+
' Please pass a `testEnvironmentOptions` object with TestEnvironmentOptions interface instead,' +
|
|
31
|
+
' see https://angular.io/api/core/testing/TestEnvironmentOptions'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
testEnvironmentOptions = {
|
|
35
|
+
...testEnvironmentOptions,
|
|
36
|
+
teardown: configuredTeardown,
|
|
37
|
+
};
|
|
27
38
|
}
|
|
39
|
+
|
|
40
|
+
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), testEnvironmentOptions);
|
package/setup-jest.mjs
CHANGED
|
@@ -2,22 +2,36 @@ import 'zone.js/fesm2015/zone-testing-bundle.min.js';
|
|
|
2
2
|
import { getTestBed } from '@angular/core/testing';
|
|
3
3
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
4
4
|
|
|
5
|
-
let
|
|
6
|
-
const configuredDestroyAfterEach = globalThis.ngJest?.destroyAfterEach;
|
|
5
|
+
let testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions ?? Object.create(null);
|
|
7
6
|
|
|
7
|
+
const configuredDestroyAfterEach = globalThis.ngJest?.destroyAfterEach;
|
|
8
8
|
if (configuredDestroyAfterEach) {
|
|
9
|
-
console.warn(
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
console.warn(
|
|
10
|
+
'Passing destroyAfterEach for configuring the test environment has been deprecated.' +
|
|
11
|
+
' Please pass a `testEnvironmentOptions` object with TestEnvironmentOptions interface instead,' +
|
|
12
|
+
' see https://angular.io/api/core/testing/TestEnvironmentOptions',
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
testEnvironmentOptions = {
|
|
16
|
+
...testEnvironmentOptions,
|
|
17
|
+
teardown: {
|
|
18
|
+
destroyAfterEach: true,
|
|
19
|
+
},
|
|
14
20
|
};
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const configuredTeardown = globalThis.ngJest?.teardown;
|
|
24
|
+
if (configuredTeardown) {
|
|
25
|
+
console.warn(
|
|
26
|
+
'Passing teardown for configuring the test environment has been deprecated.' +
|
|
27
|
+
' Please pass a `testEnvironmentOptions` object with TestEnvironmentOptions interface instead,' +
|
|
28
|
+
' see https://angular.io/api/core/testing/TestEnvironmentOptions',
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
testEnvironmentOptions = {
|
|
32
|
+
...testEnvironmentOptions,
|
|
33
|
+
teardown: configuredTeardown,
|
|
34
|
+
};
|
|
23
35
|
}
|
|
36
|
+
|
|
37
|
+
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), testEnvironmentOptions);
|
package/renovate.json
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"group:babelMonorepo",
|
|
4
|
-
"group:commitlintMonorepo",
|
|
5
|
-
"group:docusaurusMonorepo",
|
|
6
|
-
":prHourlyLimit2",
|
|
7
|
-
"workarounds:all"
|
|
8
|
-
],
|
|
9
|
-
"dependencyDashboard": false,
|
|
10
|
-
"timezone": "UTC",
|
|
11
|
-
"rangeStrategy": "bump",
|
|
12
|
-
"separateMajorMinor": true,
|
|
13
|
-
"prConcurrentLimit": 2,
|
|
14
|
-
"semanticCommits": "enabled",
|
|
15
|
-
"commitMessagePrefix": "build(deps):",
|
|
16
|
-
"ignoreDeps": [
|
|
17
|
-
"@mdx-js/react",
|
|
18
|
-
"@types/react",
|
|
19
|
-
"execa",
|
|
20
|
-
"chalk",
|
|
21
|
-
"react",
|
|
22
|
-
"react-dom"
|
|
23
|
-
],
|
|
24
|
-
"packageRules": [
|
|
25
|
-
{
|
|
26
|
-
"matchPaths": ["examples/**"],
|
|
27
|
-
"matchUpdateTypes": ["major"],
|
|
28
|
-
"enabled": false
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"matchPaths": ["package.json"],
|
|
32
|
-
"matchPackagePatterns": ["^@angular", "ng-packagr"],
|
|
33
|
-
"matchUpdateTypes": ["patch", "minor"],
|
|
34
|
-
"groupName": "Angular packages"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"matchPaths": ["package.json"],
|
|
38
|
-
"matchPackagePatterns": ["jest"],
|
|
39
|
-
"excludePackageNames": ["eslint-plugin-jest"],
|
|
40
|
-
"matchUpdateTypes": ["patch", "minor"],
|
|
41
|
-
"groupName": "Jest packages"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"extends": ["packages:eslint"],
|
|
45
|
-
"groupName": "ESLint packages"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"matchPackagePrefixes": ["esbuild"],
|
|
49
|
-
"groupName": "Esbuild packages"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"matchPackageNames": [
|
|
53
|
-
"angular-in-memory-web-api",
|
|
54
|
-
"rxjs",
|
|
55
|
-
"tslib",
|
|
56
|
-
"typescript"
|
|
57
|
-
],
|
|
58
|
-
"matchUpdateTypes": ["major", "minor"],
|
|
59
|
-
"enabled": false
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"matchPackageNames": [
|
|
63
|
-
"angular-in-memory-web-api",
|
|
64
|
-
"rxjs",
|
|
65
|
-
"tslib",
|
|
66
|
-
"typescript"
|
|
67
|
-
],
|
|
68
|
-
"matchUpdateTypes": ["patch"],
|
|
69
|
-
"enabled": true
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"matchFiles": ["package.json"],
|
|
73
|
-
"matchDepTypes": ["dependencies", "optionalDependencies"],
|
|
74
|
-
"rangeStrategy": "in-range-only"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"matchDepTypes": ["peerDependencies"],
|
|
78
|
-
"enabled": false
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|