jest-preset-angular 12.2.4 → 12.2.6
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 +13 -0
- package/build/config/global-setup.js +10 -2
- package/build/ng-jest-transformer.js +15 -5
- package/build/ngtsc/reflection/index.js +15 -2
- package/build/ngtsc/reflection/src/host.js +4 -2
- package/build/ngtsc/reflection/src/type_to_value.js +4 -2
- package/build/ngtsc/reflection/src/typescript.js +8 -5
- package/build/ngtsc/reflection/src/util.js +4 -2
- package/build/ngtsc/ts_compatibility/index.js +15 -2
- package/build/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +62 -16
- package/build/presets/index.js +4 -2
- package/build/serializers/ng-snapshot.js +2 -1
- package/build/transformers/downlevel_decorators_transform/downlevel_decorators_transform.js +20 -29
- package/build/transformers/downlevel_decorators_transform/patch_alias_reference_resolution.js +4 -2
- package/build/transformers/replace-resources.js +4 -2
- package/build/utils/ngcc-jest-processor.js +4 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [12.2.6](https://github.com/thymikee/jest-preset-angular/compare/v12.2.5...v12.2.6) (2023-01-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **serializers:** remove `__ngContext__` from snapshots ([#1816](https://github.com/thymikee/jest-preset-angular/issues/1816)) ([6997b0b](https://github.com/thymikee/jest-preset-angular/commit/6997b0bc2020e8b7d88d55a107f03c60f8ab8ee1))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [12.2.5](https://github.com/thymikee/jest-preset-angular/compare/v12.2.4...v12.2.5) (2023-01-18)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [12.2.4](https://github.com/thymikee/jest-preset-angular/compare/v12.2.3...v12.2.4) (2023-01-16)
|
|
2
15
|
|
|
3
16
|
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.globalSetup = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
13
|
const ngcc_jest_processor_1 = require("../utils/ngcc-jest-processor");
|
|
6
|
-
const globalSetup = () =>
|
|
14
|
+
const globalSetup = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
15
|
const ngJestConfig = globalThis.ngJest;
|
|
8
16
|
const tsconfig = ngJestConfig === null || ngJestConfig === void 0 ? void 0 : ngJestConfig.tsconfig;
|
|
9
17
|
if (!(ngJestConfig === null || ngJestConfig === void 0 ? void 0 : ngJestConfig.skipNgcc)) {
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
2
13
|
var _NgJestTransformer_ngJestLogger, _NgJestTransformer_esbuildImpl;
|
|
3
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
15
|
exports.NgJestTransformer = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
16
|
const child_process_1 = require("child_process");
|
|
7
17
|
const bs_logger_1 = require("bs-logger");
|
|
8
18
|
const ts_jest_transformer_1 = require("ts-jest/dist/legacy/ts-jest-transformer");
|
|
@@ -15,7 +25,7 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
15
25
|
super();
|
|
16
26
|
_NgJestTransformer_ngJestLogger.set(this, void 0);
|
|
17
27
|
_NgJestTransformer_esbuildImpl.set(this, void 0);
|
|
18
|
-
|
|
28
|
+
__classPrivateFieldSet(this, _NgJestTransformer_ngJestLogger, (0, bs_logger_1.createLogger)({
|
|
19
29
|
context: {
|
|
20
30
|
[bs_logger_1.LogContexts.package]: 'jest-preset-angular',
|
|
21
31
|
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
|
@@ -33,7 +43,7 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
33
43
|
useNativeEsbuild = false;
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
|
-
|
|
46
|
+
__classPrivateFieldSet(this, _NgJestTransformer_esbuildImpl, useNativeEsbuild ? require('esbuild') : require('esbuild-wasm'), "f");
|
|
37
47
|
}
|
|
38
48
|
_createConfigSet(config) {
|
|
39
49
|
return new ng_jest_config_1.NgJestConfig(config);
|
|
@@ -44,9 +54,9 @@ class NgJestTransformer extends ts_jest_transformer_1.TsJestTransformer {
|
|
|
44
54
|
process(fileContent, filePath, transformOptions) {
|
|
45
55
|
const configSet = super._configsFor(transformOptions);
|
|
46
56
|
if (configSet.processWithEsbuild(filePath)) {
|
|
47
|
-
|
|
57
|
+
__classPrivateFieldGet(this, _NgJestTransformer_ngJestLogger, "f").debug({ filePath }, 'process with esbuild');
|
|
48
58
|
const compilerOpts = configSet.parsedTsConfig.options;
|
|
49
|
-
const { code, map } =
|
|
59
|
+
const { code, map } = __classPrivateFieldGet(this, _NgJestTransformer_esbuildImpl, "f").transformSync(fileContent, {
|
|
50
60
|
loader: 'js',
|
|
51
61
|
format: transformOptions.supportsStaticESM && configSet.useESM ? 'esm' : 'cjs',
|
|
52
62
|
target: compilerOpts.target === configSet.compilerModule.ScriptTarget.ES2015 ? 'es2015' : 'es2016',
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.isNamedVariableDeclaration = exports.isNamedFunctionDeclaration = exports.isNamedClassDeclaration = exports.reflectTypeEntityToDeclaration = exports.reflectObjectLiteral = exports.reflectNameOfDeclaration = exports.reflectIdentifierOfDeclaration = exports.filterToMembersWithDecorator = exports.TypeScriptReflectionHost = exports.typeNodeToValueExpr = void 0;
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./src/host"), exports);
|
|
18
|
+
__exportStar(require("./src/host"), exports);
|
|
6
19
|
var type_to_value_1 = require("./src/type_to_value");
|
|
7
20
|
Object.defineProperty(exports, "typeNodeToValueExpr", { enumerable: true, get: function () { return type_to_value_1.typeNodeToValueExpr; } });
|
|
8
21
|
var typescript_1 = require("./src/typescript");
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isConcreteDeclaration = exports.KnownDeclaration = exports.ClassMemberKind = exports.isDecoratorIdentifier = exports.Decorator = void 0;
|
|
4
|
-
const
|
|
5
|
-
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
8
|
exports.Decorator = {
|
|
7
9
|
nodeForError: (decorator) => {
|
|
8
10
|
if (decorator.node !== null) {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.typeNodeToValueExpr = exports.typeToValue = void 0;
|
|
4
|
-
const
|
|
5
|
-
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
8
|
function typeToValue(typeNode, checker) {
|
|
7
9
|
if (typeNode === null) {
|
|
8
10
|
return missingType();
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.reflectObjectLiteral = exports.findMember = exports.filterToMembersWithDecorator = exports.reflectTypeEntityToDeclaration = exports.reflectIdentifierOfDeclaration = exports.reflectNameOfDeclaration = exports.TypeScriptReflectionHost = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const ts_compatibility_1 = require("../../ts_compatibility");
|
|
6
9
|
const host_1 = require("./host");
|
|
7
10
|
const type_to_value_1 = require("./type_to_value");
|
|
8
11
|
const util_1 = require("./util");
|
|
@@ -11,7 +14,7 @@ class TypeScriptReflectionHost {
|
|
|
11
14
|
this.checker = checker;
|
|
12
15
|
}
|
|
13
16
|
getDecoratorsOfDeclaration(declaration) {
|
|
14
|
-
const decorators =
|
|
17
|
+
const decorators = (0, ts_compatibility_1.getDecorators)(declaration);
|
|
15
18
|
return decorators !== undefined && decorators.length ?
|
|
16
19
|
decorators.map(decorator => this._reflectDecorator(decorator))
|
|
17
20
|
.filter((dec) => dec !== null) :
|
|
@@ -149,7 +152,7 @@ class TypeScriptReflectionHost {
|
|
|
149
152
|
if (typescript_1.default.isVariableDeclaration(decl) && typescript_1.default.isVariableDeclarationList(decl.parent)) {
|
|
150
153
|
topLevel = decl.parent.parent;
|
|
151
154
|
}
|
|
152
|
-
const modifiers =
|
|
155
|
+
const modifiers = (0, ts_compatibility_1.getModifiers)(topLevel);
|
|
153
156
|
if (modifiers !== undefined &&
|
|
154
157
|
modifiers.some(modifier => modifier.kind === typescript_1.default.SyntaxKind.ExportKeyword)) {
|
|
155
158
|
return true;
|
|
@@ -311,7 +314,7 @@ class TypeScriptReflectionHost {
|
|
|
311
314
|
return null;
|
|
312
315
|
}
|
|
313
316
|
const decorators = this.getDecoratorsOfDeclaration(node);
|
|
314
|
-
const modifiers =
|
|
317
|
+
const modifiers = (0, ts_compatibility_1.getModifiers)(node);
|
|
315
318
|
const isStatic = modifiers !== undefined && modifiers.some(mod => mod.kind === typescript_1.default.SyntaxKind.StaticKeyword);
|
|
316
319
|
return {
|
|
317
320
|
node,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isNamedVariableDeclaration = exports.isNamedFunctionDeclaration = exports.isNamedClassDeclaration = void 0;
|
|
4
|
-
const
|
|
5
|
-
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
8
|
function isNamedClassDeclaration(node) {
|
|
7
9
|
return typescript_1.default.isClassDeclaration(node) && isIdentifier(node.name);
|
|
8
10
|
}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./src/ts_cross_version_utils"), exports);
|
|
17
|
+
__exportStar(require("./src/ts_cross_version_utils"), exports);
|
|
@@ -6,23 +6,69 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
typescript_1.default.factory.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
typescript_1.default.factory.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
typescript_1.default.factory.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
typescript_1.default.factory.
|
|
25
|
-
|
|
13
|
+
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 = void 0;
|
|
14
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
15
|
+
const IS_AFTER_TS_48 = isAfterVersion(4, 8);
|
|
16
|
+
exports.updateParameterDeclaration = IS_AFTER_TS_48 ?
|
|
17
|
+
typescript_1.default.factory.updateParameterDeclaration :
|
|
18
|
+
(node, modifiers, dotDotDotToken, name, questionToken, type, initializer) => typescript_1.default.factory.updateParameterDeclaration(node, ...splitModifiers(modifiers), dotDotDotToken, name, questionToken, type, initializer);
|
|
19
|
+
exports.updateImportDeclaration = IS_AFTER_TS_48 ?
|
|
20
|
+
typescript_1.default.factory.updateImportDeclaration :
|
|
21
|
+
(node, modifiers, importClause, moduleSpecifier, assertClause) => typescript_1.default.factory.updateImportDeclaration(node, undefined, modifiers, importClause, moduleSpecifier, assertClause);
|
|
22
|
+
exports.updateClassDeclaration = IS_AFTER_TS_48 ?
|
|
23
|
+
typescript_1.default.factory.updateClassDeclaration :
|
|
24
|
+
(node, combinedModifiers, name, typeParameters, heritageClauses, members) => typescript_1.default.factory.updateClassDeclaration(node, ...splitModifiers(combinedModifiers), name, typeParameters, heritageClauses, members);
|
|
25
|
+
exports.createClassDeclaration = IS_AFTER_TS_48 ?
|
|
26
|
+
typescript_1.default.factory.createClassDeclaration :
|
|
27
|
+
(combinedModifiers, name, typeParameters, heritageClauses, members) => typescript_1.default.factory.createClassDeclaration(...splitModifiers(combinedModifiers), name, typeParameters, heritageClauses, members);
|
|
28
|
+
exports.updateMethodDeclaration = IS_AFTER_TS_48 ?
|
|
29
|
+
typescript_1.default.factory.updateMethodDeclaration :
|
|
30
|
+
(node, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) => typescript_1.default.factory.updateMethodDeclaration(node, ...splitModifiers(modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body);
|
|
31
|
+
exports.createMethodDeclaration = IS_AFTER_TS_48 ?
|
|
32
|
+
typescript_1.default.factory.createMethodDeclaration :
|
|
33
|
+
(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) => typescript_1.default.factory.createMethodDeclaration(...splitModifiers(modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body);
|
|
34
|
+
exports.updatePropertyDeclaration = IS_AFTER_TS_48 ?
|
|
35
|
+
typescript_1.default.factory.updatePropertyDeclaration :
|
|
36
|
+
(node, modifiers, name, questionOrExclamationToken, type, initializer) => typescript_1.default.factory.updatePropertyDeclaration(node, ...splitModifiers(modifiers), name, questionOrExclamationToken, type, initializer);
|
|
37
|
+
exports.createPropertyDeclaration = IS_AFTER_TS_48 ?
|
|
38
|
+
typescript_1.default.factory.createPropertyDeclaration :
|
|
39
|
+
(modifiers, name, questionOrExclamationToken, type, initializer) => typescript_1.default.factory.createPropertyDeclaration(...splitModifiers(modifiers), name, questionOrExclamationToken, type, initializer);
|
|
40
|
+
exports.updateGetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
41
|
+
typescript_1.default.factory.updateGetAccessorDeclaration :
|
|
42
|
+
(node, modifiers, name, parameters, type, body) => typescript_1.default.factory.updateGetAccessorDeclaration(node, ...splitModifiers(modifiers), name, parameters, type, body);
|
|
43
|
+
exports.createGetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
44
|
+
typescript_1.default.factory.createGetAccessorDeclaration :
|
|
45
|
+
(modifiers, name, parameters, type, body) => typescript_1.default.factory.createGetAccessorDeclaration(...splitModifiers(modifiers), name, parameters, type, body);
|
|
46
|
+
exports.updateSetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
47
|
+
typescript_1.default.factory.updateSetAccessorDeclaration :
|
|
48
|
+
(node, modifiers, name, parameters, body) => typescript_1.default.factory.updateSetAccessorDeclaration(node, ...splitModifiers(modifiers), name, parameters, body);
|
|
49
|
+
exports.createSetAccessorDeclaration = IS_AFTER_TS_48 ?
|
|
50
|
+
typescript_1.default.factory.createSetAccessorDeclaration :
|
|
51
|
+
(modifiers, name, parameters, body) => typescript_1.default.factory.createSetAccessorDeclaration(...splitModifiers(modifiers), name, parameters, body);
|
|
52
|
+
exports.updateConstructorDeclaration = IS_AFTER_TS_48 ?
|
|
53
|
+
typescript_1.default.factory.updateConstructorDeclaration :
|
|
54
|
+
(node, modifiers, parameters, body) => typescript_1.default.factory.updateConstructorDeclaration(node, undefined, modifiers, parameters, body);
|
|
55
|
+
exports.getDecorators = IS_AFTER_TS_48 ? typescript_1.default.getDecorators : node => node.decorators;
|
|
56
|
+
exports.getModifiers = IS_AFTER_TS_48 ? typescript_1.default.getModifiers : node => node.modifiers;
|
|
57
|
+
function combineModifiers(decorators, modifiers) {
|
|
58
|
+
const hasDecorators = decorators === null || decorators === void 0 ? void 0 : decorators.length;
|
|
59
|
+
const hasModifiers = modifiers === null || modifiers === void 0 ? void 0 : modifiers.length;
|
|
60
|
+
if (hasDecorators && hasModifiers) {
|
|
61
|
+
return [...decorators, ...modifiers];
|
|
62
|
+
}
|
|
63
|
+
if (hasDecorators && !hasModifiers) {
|
|
64
|
+
return decorators;
|
|
65
|
+
}
|
|
66
|
+
if (hasModifiers && !hasDecorators) {
|
|
67
|
+
return modifiers;
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
exports.combineModifiers = combineModifiers;
|
|
26
72
|
function splitModifiers(allModifiers) {
|
|
27
73
|
if (!allModifiers) {
|
|
28
74
|
return [undefined, undefined];
|
package/build/presets/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.defaultEsmPreset = exports.defaultPreset = void 0;
|
|
4
|
-
const
|
|
5
|
-
const serializers_1 = tslib_1.__importDefault(require("../serializers"));
|
|
7
|
+
const serializers_1 = __importDefault(require("../serializers"));
|
|
6
8
|
const baseConfig = {
|
|
7
9
|
globals: {
|
|
8
10
|
'ts-jest': {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const attributesToRemovePatterns = ['__ngContext__'];
|
|
2
3
|
const ivyEnabled = () => {
|
|
3
4
|
const { ɵivyEnabled } = require('@angular/core');
|
|
4
5
|
return ɵivyEnabled;
|
|
@@ -22,7 +23,7 @@ const print = (fixture, print, indent, opts, colors) => {
|
|
|
22
23
|
.map((node) => Array.from(node.renderElement.childNodes).map(print).join(''))
|
|
23
24
|
.join(opts.edgeSpacing);
|
|
24
25
|
}
|
|
25
|
-
const attributes = Object.keys(componentInstance);
|
|
26
|
+
const attributes = Object.keys(componentInstance).filter((key) => !attributesToRemovePatterns.includes(key));
|
|
26
27
|
if (attributes.length) {
|
|
27
28
|
componentAttrs += attributes
|
|
28
29
|
.sort()
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getDownlevelDecoratorsTransform = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const ts_compatibility_1 = require("../../ngtsc/ts_compatibility");
|
|
6
9
|
const patch_alias_reference_resolution_1 = require("./patch_alias_reference_resolution");
|
|
7
10
|
function isAngularDecorator(decorator, isCore) {
|
|
8
11
|
return isCore || (decorator.import !== null && decorator.import.from === '@angular/core');
|
|
@@ -61,7 +64,7 @@ function createCtorParametersClassProperty(diagnostics, entityNameToExpression,
|
|
|
61
64
|
params.push(typescript_1.default.factory.createObjectLiteralExpression(members));
|
|
62
65
|
}
|
|
63
66
|
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 =
|
|
67
|
+
const ctorProp = (0, ts_compatibility_1.createPropertyDeclaration)([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], 'ctorParameters', undefined, undefined, initializer);
|
|
65
68
|
if (isClosureCompilerEnabled) {
|
|
66
69
|
typescript_1.default.setSyntheticLeadingComments(ctorProp, [
|
|
67
70
|
{
|
|
@@ -145,7 +148,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
145
148
|
function createDecoratorClassProperty(decoratorList) {
|
|
146
149
|
const modifier = typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword);
|
|
147
150
|
const initializer = typescript_1.default.factory.createArrayLiteralExpression(decoratorList, true);
|
|
148
|
-
const prop =
|
|
151
|
+
const prop = (0, ts_compatibility_1.createPropertyDeclaration)([modifier], 'decorators', undefined, undefined, initializer);
|
|
149
152
|
addJSDocTypeAnnotation(prop, DECORATOR_INVOCATION_JSDOC_TYPE);
|
|
150
153
|
return prop;
|
|
151
154
|
}
|
|
@@ -155,7 +158,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
155
158
|
entries.push(typescript_1.default.factory.createPropertyAssignment(name, typescript_1.default.factory.createArrayLiteralExpression(decorators.map(deco => extractMetadataFromSingleDecorator(deco, diagnostics)))));
|
|
156
159
|
}
|
|
157
160
|
const initializer = typescript_1.default.factory.createObjectLiteralExpression(entries, true);
|
|
158
|
-
const prop =
|
|
161
|
+
const prop = (0, ts_compatibility_1.createPropertyDeclaration)([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], 'propDecorators', undefined, undefined, initializer);
|
|
159
162
|
addJSDocTypeAnnotation(prop, `!Object<string, ${DECORATOR_INVOCATION_JSDOC_TYPE}>`);
|
|
160
163
|
return prop;
|
|
161
164
|
}
|
|
@@ -209,11 +212,9 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
209
212
|
});
|
|
210
213
|
return [undefined, element, []];
|
|
211
214
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
modifiers = typescript_1.default.setTextRange(typescript_1.default.factory.createNodeArray([...decoratorsToKeep, ...(elementModifiers || [])]), element.modifiers);
|
|
216
|
-
}
|
|
215
|
+
const modifiers = decoratorsToKeep.length ?
|
|
216
|
+
typescript_1.default.setTextRange(typescript_1.default.factory.createNodeArray((0, ts_compatibility_1.combineModifiers)(decoratorsToKeep, (0, ts_compatibility_1.getModifiers)(element))), element.modifiers) :
|
|
217
|
+
(0, ts_compatibility_1.getModifiers)(element);
|
|
217
218
|
return [element.name.text, cloneClassElementWithModifiers(element, modifiers), toLower];
|
|
218
219
|
}
|
|
219
220
|
function transformConstructor(ctor) {
|
|
@@ -237,15 +238,10 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
237
238
|
paramInfo.type = param.type;
|
|
238
239
|
}
|
|
239
240
|
parametersInfo.push(paramInfo);
|
|
240
|
-
|
|
241
|
-
const paramModifiers = typescript_1.default.getModifiers(param);
|
|
242
|
-
if (decoratorsToKeep.length || (paramModifiers === null || paramModifiers === void 0 ? void 0 : paramModifiers.length)) {
|
|
243
|
-
modifiers = [...decoratorsToKeep, ...(paramModifiers || [])];
|
|
244
|
-
}
|
|
245
|
-
const newParam = typescript_1.default.factory.updateParameterDeclaration(param, modifiers, param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
|
|
241
|
+
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);
|
|
246
242
|
newParameters.push(newParam);
|
|
247
243
|
}
|
|
248
|
-
const updated =
|
|
244
|
+
const updated = (0, ts_compatibility_1.updateConstructorDeclaration)(ctor, (0, ts_compatibility_1.getModifiers)(ctor), newParameters, ctor.body);
|
|
249
245
|
return [updated, parametersInfo];
|
|
250
246
|
}
|
|
251
247
|
function transformClassDeclaration(classDecl) {
|
|
@@ -278,7 +274,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
278
274
|
}
|
|
279
275
|
newMembers.push(typescript_1.default.visitEachChild(member, decoratorDownlevelVisitor, context));
|
|
280
276
|
}
|
|
281
|
-
const decoratorsToKeep = new Set(
|
|
277
|
+
const decoratorsToKeep = new Set((0, ts_compatibility_1.getDecorators)(classDecl));
|
|
282
278
|
const possibleAngularDecorators = host.getDecoratorsOfDeclaration(classDecl) || [];
|
|
283
279
|
let hasAngularDecorator = false;
|
|
284
280
|
const decoratorsToLower = [];
|
|
@@ -305,12 +301,7 @@ function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore,
|
|
|
305
301
|
newMembers.push(createPropDecoratorsClassProperty(diagnostics, decoratedProperties));
|
|
306
302
|
}
|
|
307
303
|
const members = typescript_1.default.setTextRange(typescript_1.default.factory.createNodeArray(newMembers, classDecl.members.hasTrailingComma), classDecl.members);
|
|
308
|
-
|
|
309
|
-
let modifiers;
|
|
310
|
-
if (decoratorsToKeep.size || (classModifiers === null || classModifiers === void 0 ? void 0 : classModifiers.length)) {
|
|
311
|
-
modifiers = [...decoratorsToKeep, ...(classModifiers || [])];
|
|
312
|
-
}
|
|
313
|
-
return typescript_1.default.factory.updateClassDeclaration(classDecl, modifiers, classDecl.name, classDecl.typeParameters, classDecl.heritageClauses, members);
|
|
304
|
+
return (0, ts_compatibility_1.updateClassDeclaration)(classDecl, (0, ts_compatibility_1.combineModifiers)(decoratorsToKeep.size ? Array.from(decoratorsToKeep) : undefined, (0, ts_compatibility_1.getModifiers)(classDecl)), classDecl.name, classDecl.typeParameters, classDecl.heritageClauses, members);
|
|
314
305
|
}
|
|
315
306
|
function decoratorDownlevelVisitor(node) {
|
|
316
307
|
if (typescript_1.default.isClassDeclaration(node)) {
|
|
@@ -327,17 +318,17 @@ exports.getDownlevelDecoratorsTransform = getDownlevelDecoratorsTransform;
|
|
|
327
318
|
function cloneClassElementWithModifiers(node, modifiers) {
|
|
328
319
|
let clone;
|
|
329
320
|
if (typescript_1.default.isMethodDeclaration(node)) {
|
|
330
|
-
clone =
|
|
321
|
+
clone = (0, ts_compatibility_1.createMethodDeclaration)(modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
|
331
322
|
}
|
|
332
323
|
else if (typescript_1.default.isPropertyDeclaration(node)) {
|
|
333
|
-
clone =
|
|
324
|
+
clone = (0, ts_compatibility_1.createPropertyDeclaration)(modifiers, node.name, node.questionToken, node.type, node.initializer);
|
|
334
325
|
}
|
|
335
326
|
else if (typescript_1.default.isGetAccessor(node)) {
|
|
336
|
-
clone =
|
|
327
|
+
clone =
|
|
328
|
+
(0, ts_compatibility_1.createGetAccessorDeclaration)(modifiers, node.name, node.parameters, node.type, node.body);
|
|
337
329
|
}
|
|
338
330
|
else if (typescript_1.default.isSetAccessor(node)) {
|
|
339
|
-
clone =
|
|
340
|
-
typescript_1.default.factory.createSetAccessorDeclaration(modifiers, node.name, node.parameters, node.body);
|
|
331
|
+
clone = (0, ts_compatibility_1.createSetAccessorDeclaration)(modifiers, node.name, node.parameters, node.body);
|
|
341
332
|
}
|
|
342
333
|
else {
|
|
343
334
|
throw new Error(`Unsupported decorated member with kind ${typescript_1.default.SyntaxKind[node.kind]}`);
|
package/build/transformers/downlevel_decorators_transform/patch_alias_reference_resolution.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isAliasImportDeclaration = exports.loadIsReferencedAliasDeclarationPatch = void 0;
|
|
4
|
-
const
|
|
5
|
-
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
8
|
const patchedReferencedAliasesSymbol = Symbol('patchedReferencedAliases');
|
|
7
9
|
function loadIsReferencedAliasDeclarationPatch(context) {
|
|
8
10
|
if (!isTransformationContextWithEmitResolver(context)) {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.replaceResources = void 0;
|
|
4
|
-
const
|
|
5
|
-
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
8
|
const constants_1 = require("../constants");
|
|
7
9
|
const isAfterVersion = (targetMajor, targetMinor) => {
|
|
8
10
|
const [major, minor] = typescript_1.default.versionMajorMinor.split('.').map((part) => parseInt(part));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.runNgccJestProcessor = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
7
|
const child_process_1 = require("child_process");
|
|
6
|
-
const path_1 =
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
7
9
|
const ANGULAR_COMPILER_CLI_PKG_NAME = `@angular${path_1.default.sep}compiler-cli`;
|
|
8
10
|
let ngccPath = '';
|
|
9
11
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-preset-angular",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.6",
|
|
4
4
|
"description": "Jest preset configuration for Angular projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"testing"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "
|
|
30
|
+
"build": "tsc -p tsconfig.build.json",
|
|
31
31
|
"_postinstall": "husky install",
|
|
32
32
|
"lint": "eslint --ext .js,.ts .",
|
|
33
33
|
"lint-fix": "eslint --fix --ext .js,.ts .",
|