jest-preset-angular 8.3.2 → 8.4.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.
@@ -1,40 +1,42 @@
1
1
  'use strict';
2
- var printAttributes = function (val, attributes, print, indent, colors, opts) {
2
+ const { rootLogger } = require('ts-jest/dist/utils/logger');
3
+ rootLogger.warn("The snapshot serializer under import path `'jest-preset-angular/build/AngularSnapshotSerializer.js'` is deprecated and will be removed in v9.0.0. Please switch to `'jest-preset-angular/build/serializers/ng-snapshot'`");
4
+ const printAttributes = (val, attributes, print, indent, colors, opts) => {
3
5
  return attributes
4
6
  .sort()
5
- .map(function (attribute) {
7
+ .map((attribute) => {
6
8
  return (opts.spacing +
7
9
  indent(colors.prop.open + attribute + colors.prop.close + '=') +
8
10
  colors.value.open +
9
11
  (val.componentInstance[attribute] && val.componentInstance[attribute].constructor
10
12
  ? '{[Function ' + val.componentInstance[attribute].constructor.name + ']}'
11
- : "\"" + val.componentInstance[attribute] + "\"") +
13
+ : `"${val.componentInstance[attribute]}"`) +
12
14
  colors.value.close);
13
15
  })
14
16
  .join('');
15
17
  };
16
- var ivyEnabled = function () {
17
- var ɵivyEnabled = require('@angular/core').ɵivyEnabled;
18
+ const ivyEnabled = () => {
19
+ const { ɵivyEnabled } = require('@angular/core');
18
20
  return !!ɵivyEnabled;
19
21
  };
20
- var getComponentDef = function (type) { return type.ngComponentDef || type.ɵcmp; };
21
- var print = function (fixture, print, indent, opts, colors) {
22
- var nodes = '';
23
- var componentAttrs = '';
24
- var componentName = '';
22
+ const getComponentDef = (type) => type.ngComponentDef || type.ɵcmp;
23
+ const print = (fixture, print, indent, opts, colors) => {
24
+ let nodes = '';
25
+ let componentAttrs = '';
26
+ let componentName = '';
25
27
  if (ivyEnabled()) {
26
- var componentDef = getComponentDef(fixture.componentRef.componentType);
28
+ const componentDef = getComponentDef(fixture.componentRef.componentType);
27
29
  componentName = componentDef.selectors[0][0];
28
30
  nodes = Array.from(fixture.componentRef.location.nativeElement.childNodes).map(print).join('');
29
31
  }
30
32
  else {
31
33
  componentName = fixture.componentRef._elDef.element.name;
32
34
  nodes = (fixture.componentRef._view.nodes || [])
33
- .filter(function (node) { return node && node.hasOwnProperty('renderElement'); })
34
- .map(function (node) { return Array.from(node.renderElement.childNodes).map(print).join(''); })
35
+ .filter((node) => node && node.hasOwnProperty('renderElement'))
36
+ .map((node) => Array.from(node.renderElement.childNodes).map(print).join(''))
35
37
  .join(opts.edgeSpacing);
36
38
  }
37
- var attributes = Object.keys(fixture.componentInstance);
39
+ const attributes = Object.keys(fixture.componentInstance);
38
40
  if (attributes.length) {
39
41
  componentAttrs += printAttributes(fixture, attributes, print, indent, colors, opts);
40
42
  }
@@ -48,12 +50,10 @@ var print = function (fixture, print, indent, opts, colors) {
48
50
  componentName +
49
51
  '>');
50
52
  };
51
- var test = function (val) {
52
- return val !== undefined &&
53
- val !== null &&
54
- typeof val === 'object' &&
55
- Object.prototype.hasOwnProperty.call(val, 'componentRef');
56
- };
53
+ const test = (val) => val !== undefined &&
54
+ val !== null &&
55
+ typeof val === 'object' &&
56
+ Object.prototype.hasOwnProperty.call(val, 'componentRef');
57
57
  module.exports = {
58
58
  print: print,
59
59
  test: test,
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
- var HTML_ELEMENT_REGEXP = /Comment/;
3
- var test = function (value) {
4
- return value !== undefined &&
5
- value !== null &&
6
- value.nodeType === 8 &&
7
- value.constructor !== undefined &&
8
- HTML_ELEMENT_REGEXP.test(value.constructor.name);
9
- };
10
- var print = function () { return ''; };
2
+ const { rootLogger } = require('ts-jest/dist/utils/logger');
3
+ rootLogger.warn("The snapshot serializer under import path `'jest-preset-angular/build/HTMLCommentSerializer.js'` is deprecated and will be removed in v9.0.0. Please switch to `'jest-preset-angular/build/serializers/html-comment'`");
4
+ const HTML_ELEMENT_REGEXP = /Comment/;
5
+ const test = (value) => value !== undefined &&
6
+ value !== null &&
7
+ value.nodeType === 8 &&
8
+ value.constructor !== undefined &&
9
+ HTML_ELEMENT_REGEXP.test(value.constructor.name);
10
+ const print = () => '';
11
11
  module.exports = {
12
12
  print: print,
13
13
  test: test,
@@ -1,32 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.factory = exports.version = exports.name = void 0;
4
- var TransformUtils_1 = require("./TransformUtils");
5
- var TEMPLATE_URL = 'templateUrl';
6
- var STYLE_URLS = 'styleUrls';
7
- var TEMPLATE = 'template';
8
- var REQUIRE = 'require';
9
- var TRANSFORM_PROPS = [TEMPLATE_URL, STYLE_URLS];
4
+ const TransformUtils_1 = require("./TransformUtils");
5
+ const TEMPLATE_URL = 'templateUrl';
6
+ const STYLE_URLS = 'styleUrls';
7
+ const TEMPLATE = 'template';
8
+ const REQUIRE = 'require';
9
+ const TRANSFORM_PROPS = [TEMPLATE_URL, STYLE_URLS];
10
10
  exports.name = 'angular-component-inline-files';
11
11
  exports.version = 1;
12
12
  function factory(cs) {
13
- var ts = cs.compilerModule;
14
- var createStringLiteral = TransformUtils_1.getCreateStringLiteral(ts);
13
+ const ts = cs.compilerModule;
14
+ const createStringLiteral = TransformUtils_1.getCreateStringLiteral(ts);
15
15
  function isPropertyAssignmentToTransform(node) {
16
16
  return ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && TRANSFORM_PROPS.includes(node.name.text);
17
17
  }
18
18
  function transfromPropertyAssignmentForJest(node) {
19
- var mutableAssignment = ts.getMutableClone(node);
20
- var assignmentNameText = mutableAssignment.name.text;
19
+ const mutableAssignment = ts.getMutableClone(node);
20
+ const assignmentNameText = mutableAssignment.name.text;
21
21
  switch (assignmentNameText) {
22
22
  case TEMPLATE_URL:
23
- var pathLiteral = mutableAssignment.initializer;
23
+ let pathLiteral = mutableAssignment.initializer;
24
24
  if (ts.isStringLiteral(pathLiteral)) {
25
25
  if (pathLiteral.text && !pathLiteral.text.match(/^(\.\/|\.\.\/|\/)/)) {
26
- pathLiteral = createStringLiteral("./" + pathLiteral.text);
26
+ pathLiteral = createStringLiteral(`./${pathLiteral.text}`);
27
27
  }
28
28
  }
29
- var requireCall = ts.createCall(ts.createIdentifier(REQUIRE), undefined, [pathLiteral]);
29
+ const requireCall = ts.createCall(ts.createIdentifier(REQUIRE), undefined, [pathLiteral]);
30
30
  mutableAssignment.name = ts.createIdentifier(TEMPLATE);
31
31
  mutableAssignment.initializer = requireCall;
32
32
  break;
@@ -39,8 +39,8 @@ function factory(cs) {
39
39
  return mutableAssignment;
40
40
  }
41
41
  function createVisitor(ctx, _) {
42
- var visitor = function (node) {
43
- var resultNode = node;
42
+ const visitor = (node) => {
43
+ let resultNode = node;
44
44
  if (isPropertyAssignmentToTransform(node)) {
45
45
  resultNode = transfromPropertyAssignmentForJest(node);
46
46
  }
@@ -49,8 +49,6 @@ function factory(cs) {
49
49
  };
50
50
  return visitor;
51
51
  }
52
- return function (ctx) { return function (sf) {
53
- return ts.visitNode(sf, createVisitor(ctx, sf));
54
- }; };
52
+ return (ctx) => (sf) => ts.visitNode(sf, createVisitor(ctx, sf));
55
53
  }
56
54
  exports.factory = factory;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.factory = exports.version = exports.name = void 0;
4
- var STYLES = 'styles';
5
- var COMPONENT = 'Component';
6
- var TRANSFORM_IN_DECORATOR_PROPS = [STYLES];
4
+ const STYLES = 'styles';
5
+ const COMPONENT = 'Component';
6
+ const TRANSFORM_IN_DECORATOR_PROPS = [STYLES];
7
7
  exports.name = 'angular-component-strip-styles';
8
8
  exports.version = 1;
9
9
  function factory(cs) {
10
- var ts = cs.compilerModule;
10
+ const ts = cs.compilerModule;
11
11
  function isInDecoratorPropertyAssignmentToTransform(node) {
12
12
  return getInDecoratorPropertyAssignmentsToTransform(node).length > 0;
13
13
  }
@@ -16,25 +16,17 @@ function factory(cs) {
16
16
  return [];
17
17
  }
18
18
  return node.decorators
19
- .map(function (dec) { return dec.expression; })
19
+ .map((dec) => dec.expression)
20
20
  .filter(ts.isCallExpression)
21
- .filter(function (callExpr) {
22
- return ts.isIdentifier(callExpr.expression) && callExpr.expression.getText() === COMPONENT;
23
- })
24
- .reduce(function (acc, nxtCallExpr) {
25
- return Array.prototype.concat.apply(acc, nxtCallExpr.arguments.filter(ts.isObjectLiteralExpression).reduce(function (acc, nxtArg) {
26
- return Array.prototype.concat.apply(acc, nxtArg.properties
27
- .filter(ts.isPropertyAssignment)
28
- .filter(function (propAss) {
29
- return ts.isIdentifier(propAss.name) && TRANSFORM_IN_DECORATOR_PROPS.includes(propAss.name.text);
30
- }));
31
- }, []));
32
- }, []);
21
+ .filter((callExpr) => ts.isIdentifier(callExpr.expression) && callExpr.expression.getText() === COMPONENT)
22
+ .reduce((acc, nxtCallExpr) => Array.prototype.concat.apply(acc, nxtCallExpr.arguments.filter(ts.isObjectLiteralExpression).reduce((acc, nxtArg) => Array.prototype.concat.apply(acc, nxtArg.properties
23
+ .filter(ts.isPropertyAssignment)
24
+ .filter((propAss) => ts.isIdentifier(propAss.name) && TRANSFORM_IN_DECORATOR_PROPS.includes(propAss.name.text))), [])), []);
33
25
  }
34
26
  function transformStylesAssignmentForJest(node) {
35
- var mutableNode = ts.getMutableClone(node);
36
- var assignments = getInDecoratorPropertyAssignmentsToTransform(mutableNode);
37
- assignments.forEach(function (assignment) {
27
+ const mutableNode = ts.getMutableClone(node);
28
+ const assignments = getInDecoratorPropertyAssignmentsToTransform(mutableNode);
29
+ assignments.forEach((assignment) => {
38
30
  if (assignment.name.text === STYLES) {
39
31
  assignment.initializer = ts.createArrayLiteral();
40
32
  }
@@ -42,7 +34,7 @@ function factory(cs) {
42
34
  return mutableNode;
43
35
  }
44
36
  function createVisitor(ctx, _) {
45
- var visitor = function (node) {
37
+ const visitor = (node) => {
46
38
  if (isInDecoratorPropertyAssignmentToTransform(node)) {
47
39
  return transformStylesAssignmentForJest(node);
48
40
  }
@@ -52,8 +44,6 @@ function factory(cs) {
52
44
  };
53
45
  return visitor;
54
46
  }
55
- return function (ctx) { return function (sf) {
56
- return ts.visitNode(sf, createVisitor(ctx, sf));
57
- }; };
47
+ return (ctx) => (sf) => ts.visitNode(sf, createVisitor(ctx, sf));
58
48
  }
59
49
  exports.factory = factory;
@@ -6,7 +6,7 @@ function getCreateStringLiteral(ts) {
6
6
  return ts.createStringLiteral;
7
7
  }
8
8
  return function createStringLiteral(text) {
9
- var node = ts.createNode(ts.SyntaxKind.StringLiteral, -1, -1);
9
+ const node = ts.createNode(ts.SyntaxKind.StringLiteral, -1, -1);
10
10
  node.text = text;
11
11
  node.flags |= ts.NodeFlags.Synthesized;
12
12
  return node;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
- var METADATA_KEY_PARAMTYPES = 'design:paramtypes';
3
- var CTOR_PARAMETERS_JPA = 'ctorParametersJPA';
2
+ const METADATA_KEY_PARAMTYPES = 'design:paramtypes';
3
+ const CTOR_PARAMETERS_JPA = 'ctorParametersJPA';
4
4
  global.globalThis = global.globalThis || undefined;
5
- var _global = globalThis || global;
6
- var reflect = _global['Reflect'];
5
+ const _global = globalThis || global;
6
+ const reflect = _global['Reflect'];
7
7
  if (!reflect.metadata && !reflect.getOwnMetadata) {
8
- reflect.metadata = function (metadataKey, metadataValue) { return function (target, key) {
8
+ reflect.metadata = (metadataKey, metadataValue) => (target, key) => {
9
9
  if (metadataKey === METADATA_KEY_PARAMTYPES && key === undefined) {
10
10
  target[CTOR_PARAMETERS_JPA] = metadataValue;
11
11
  }
12
- }; };
13
- reflect.getOwnMetadata = function (metadata, target, key) {
12
+ };
13
+ reflect.getOwnMetadata = (metadata, target, key) => {
14
14
  if (metadata === METADATA_KEY_PARAMTYPES && key === undefined) {
15
15
  return target[CTOR_PARAMETERS_JPA];
16
16
  }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ const HTML_ELEMENT_REGEXP = /Comment/;
3
+ const test = (value) => (value === null || value === void 0 ? void 0 : value.nodeType) === 8 && value.constructor !== undefined && HTML_ELEMENT_REGEXP.test(value.constructor.name);
4
+ const print = () => '';
5
+ module.exports = {
6
+ print,
7
+ test,
8
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ module.exports = [
3
+ 'jest-preset-angular/build/serializers/html-comment',
4
+ 'jest-preset-angular/build/serializers/ng-snapshot',
5
+ 'jest-preset-angular/build/serializers/no-ng-attributes',
6
+ ];
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ const printAttributes = (val, attributes, _print, indent, colors, opts) => {
3
+ return attributes
4
+ .sort()
5
+ .map((attribute) => {
6
+ return (opts.spacing +
7
+ indent(`${colors.prop.open}${attribute}${colors.prop.close}=`) +
8
+ colors.value.open +
9
+ (val.componentInstance[attribute] && val.componentInstance[attribute].constructor
10
+ ? `{[Function ${val.componentInstance[attribute].constructor.name}]}`
11
+ : `"${val.componentInstance[attribute]}"`) +
12
+ colors.value.close);
13
+ })
14
+ .join('');
15
+ };
16
+ const ivyEnabled = () => {
17
+ const { ɵivyEnabled } = require('@angular/core');
18
+ return !!ɵivyEnabled;
19
+ };
20
+ const getComponentDef = (type) => { var _a; return (_a = type.ngComponentDef) !== null && _a !== void 0 ? _a : type.ɵcmp; };
21
+ const print = (fixture, print, indent, opts, colors) => {
22
+ var _a;
23
+ let nodes = '';
24
+ let componentAttrs = '';
25
+ let componentName = '';
26
+ if (ivyEnabled()) {
27
+ const componentDef = getComponentDef(fixture.componentRef.componentType);
28
+ componentName = componentDef.selectors[0][0];
29
+ nodes = Array.from(fixture.componentRef.location.nativeElement.childNodes).map(print).join('');
30
+ }
31
+ else {
32
+ componentName = (_a = fixture.componentRef._elDef.element) === null || _a === void 0 ? void 0 : _a.name;
33
+ nodes = (fixture.componentRef._view.nodes || [])
34
+ .filter((node) => node === null || node === void 0 ? void 0 : node.hasOwnProperty('renderElement'))
35
+ .map((node) => Array.from(node.renderElement.childNodes).map(print).join(''))
36
+ .join(opts.edgeSpacing);
37
+ }
38
+ const attributes = Object.keys(fixture.componentInstance);
39
+ if (attributes.length) {
40
+ componentAttrs += printAttributes(fixture, attributes, print, indent, colors, opts);
41
+ }
42
+ return ('<' +
43
+ componentName +
44
+ componentAttrs +
45
+ (componentAttrs.length ? '\n' : '') +
46
+ '>\n' +
47
+ indent(nodes) +
48
+ '\n</' +
49
+ componentName +
50
+ '>');
51
+ };
52
+ const test = (val) => val !== undefined &&
53
+ val !== null &&
54
+ typeof val === 'object' &&
55
+ Object.prototype.hasOwnProperty.call(val, 'componentRef');
56
+ module.exports = {
57
+ print,
58
+ test,
59
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ const pretty_format_1 = require("pretty-format");
3
+ const jestDOMElementSerializer = pretty_format_1.plugins.DOMElement;
4
+ const attributesToRemovePatterns = ['ng-reflect', '_nghost', '_ngcontent', 'ng-version'];
5
+ const attributesToClean = {
6
+ class: [/^(?:mat|cdk|ng).*-\w*\d+-\d+$/, /^ng-star-inserted$/],
7
+ id: [/^(?:mat|cdk|ng).*-\d+$/],
8
+ for: [/^(?:mat|cdk|ng).*-\d+$/],
9
+ 'aria-owns': [/^(?:mat|cdk|ng).*-\d+$/],
10
+ 'aria-labelledby': [/^(?:mat|cdk|ng).*-\d+$/],
11
+ 'aria-controls': [/^(?:mat|cdk|ng).*-\d+$/],
12
+ };
13
+ const hasAttributesToRemove = (attribute) => attributesToRemovePatterns.some((removePattern) => attribute.name.startsWith(removePattern));
14
+ const hasAttributesToClean = (attribute) => Object.keys(attributesToClean).some((removePatternKey) => attribute.name === removePatternKey);
15
+ const serialize = (node, ...rest) => {
16
+ const nodeCopy = node.cloneNode(true);
17
+ Object.values(nodeCopy.attributes)
18
+ .filter(hasAttributesToRemove)
19
+ .forEach((attribute) => nodeCopy.attributes.removeNamedItem(attribute.name));
20
+ Object.values(nodeCopy.attributes)
21
+ .filter(hasAttributesToClean)
22
+ .forEach((attribute) => {
23
+ attribute.value = attribute.value
24
+ .split(' ')
25
+ .filter((attrValue) => !attributesToClean[attribute.name].some((attributeCleanRegex) => attributeCleanRegex.test(attrValue)))
26
+ .join(' ');
27
+ if (attribute.value === '') {
28
+ nodeCopy.attributes.removeNamedItem(attribute.name);
29
+ }
30
+ else {
31
+ nodeCopy.attributes.setNamedItem(attribute);
32
+ }
33
+ });
34
+ return jestDOMElementSerializer.serialize(nodeCopy, ...rest);
35
+ };
36
+ const serializeTestFn = (val) => val.attributes !== undefined &&
37
+ Object.values(val.attributes).some((attribute) => hasAttributesToRemove(attribute) || hasAttributesToClean(attribute));
38
+ const test = (val) => jestDOMElementSerializer.test(val) && serializeTestFn(val);
39
+ module.exports = {
40
+ serialize,
41
+ test,
42
+ };
@@ -11,8 +11,8 @@ catch (err) {
11
11
  require('zone.js/dist/fake-async-test');
12
12
  require('./zone-patch');
13
13
  }
14
- var getTestBed = require('@angular/core/testing').getTestBed;
15
- var BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
16
- var platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing')
14
+ const getTestBed = require('@angular/core/testing').getTestBed;
15
+ const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
16
+ const platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing')
17
17
  .platformBrowserDynamicTesting;
18
18
  getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const child_process_1 = require("child_process");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const IGNORE_ARGS = ['--clearCache', '--help', '--init', '--listTests', '--showConfig'];
8
+ const canRunNgcc = !process.argv.find((arg) => IGNORE_ARGS.includes(arg));
9
+ function findNodeModulesDirectory(startPoint) {
10
+ let current = startPoint;
11
+ while (path_1.dirname(current) !== current) {
12
+ const nodePath = path_1.join(current, 'node_modules');
13
+ if (fs_1.existsSync(nodePath)) {
14
+ return nodePath;
15
+ }
16
+ current = path_1.dirname(current);
17
+ }
18
+ throw new Error(`Cannot locate the 'node_modules' directory. Please make sure you are running jest from root level of your project`);
19
+ }
20
+ if (canRunNgcc) {
21
+ process.stdout.write('ngcc-jest-processor: running ngcc\n');
22
+ const { status, error } = child_process_1.spawnSync(process.execPath, [
23
+ require.resolve('@angular/compiler-cli/ngcc/main-ngcc.js'),
24
+ '--source',
25
+ findNodeModulesDirectory(process.cwd()),
26
+ '--properties',
27
+ ...['es2015', 'main'],
28
+ '--first-only',
29
+ 'false',
30
+ '--async',
31
+ ], {
32
+ stdio: ['inherit', process.stderr, process.stderr],
33
+ });
34
+ if (status !== 0) {
35
+ const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
36
+ throw new Error(`${errorMessage} NGCC failed ${errorMessage ? ', see above' : ''}.`);
37
+ }
38
+ }
@@ -11,32 +11,28 @@ if (jest['__zone_patch__'] === true) {
11
11
  throw new Error("'jest' has already been patched with 'Zone'.");
12
12
  }
13
13
  jest['__zone_patch__'] = true;
14
- var SyncTestZoneSpec = Zone['SyncTestZoneSpec'];
15
- var ProxyZoneSpec = Zone['ProxyZoneSpec'];
14
+ const SyncTestZoneSpec = Zone['SyncTestZoneSpec'];
15
+ const ProxyZoneSpec = Zone['ProxyZoneSpec'];
16
16
  if (SyncTestZoneSpec === undefined) {
17
17
  throw new Error('Missing: SyncTestZoneSpec (zone.js/dist/sync-test)');
18
18
  }
19
19
  if (ProxyZoneSpec === undefined) {
20
20
  throw new Error('Missing: ProxyZoneSpec (zone.js/dist/proxy.js)');
21
21
  }
22
- var env = global;
23
- var ambientZone = Zone.current;
24
- var syncZone = ambientZone.fork(new SyncTestZoneSpec('jest.describe'));
22
+ const env = global;
23
+ const ambientZone = Zone.current;
24
+ const syncZone = ambientZone.fork(new SyncTestZoneSpec('jest.describe'));
25
25
  function wrapDescribeInZone(describeBody) {
26
- return function () {
27
- var args = [];
28
- for (var _i = 0; _i < arguments.length; _i++) {
29
- args[_i] = arguments[_i];
30
- }
26
+ return function (...args) {
31
27
  return syncZone.run(describeBody, null, args);
32
28
  };
33
29
  }
34
- var testProxyZone = ambientZone.fork(new ProxyZoneSpec());
30
+ const testProxyZone = ambientZone.fork(new ProxyZoneSpec());
35
31
  function wrapTestInZone(testBody) {
36
32
  if (testBody === undefined) {
37
33
  return;
38
34
  }
39
- var wrappedFunc = function () {
35
+ const wrappedFunc = function () {
40
36
  return testProxyZone.run(testBody, null, arguments);
41
37
  };
42
38
  try {
@@ -49,50 +45,26 @@ function wrapTestInZone(testBody) {
49
45
  }
50
46
  catch (e) {
51
47
  return testBody.length === 0
52
- ? function () { return testProxyZone.run(testBody, null); }
53
- : function (done) { return testProxyZone.run(testBody, null, [done]); };
48
+ ? () => testProxyZone.run(testBody, null)
49
+ : (done) => testProxyZone.run(testBody, null, [done]);
54
50
  }
55
51
  return wrappedFunc;
56
52
  }
57
- var bindDescribe = function (originalJestFn) {
58
- return function () {
59
- var eachArgs = [];
60
- for (var _i = 0; _i < arguments.length; _i++) {
61
- eachArgs[_i] = arguments[_i];
62
- }
63
- return function () {
64
- var args = [];
65
- for (var _i = 0; _i < arguments.length; _i++) {
66
- args[_i] = arguments[_i];
67
- }
68
- args[1] = wrapDescribeInZone(args[1]);
69
- return originalJestFn.apply(this, eachArgs).apply(this, args);
70
- };
53
+ const bindDescribe = (originalJestFn) => function (...eachArgs) {
54
+ return function (...args) {
55
+ args[1] = wrapDescribeInZone(args[1]);
56
+ return originalJestFn.apply(this, eachArgs).apply(this, args);
71
57
  };
72
58
  };
73
- var bindTest = function (originalJestFn) {
74
- return function () {
75
- var eachArgs = [];
76
- for (var _i = 0; _i < arguments.length; _i++) {
77
- eachArgs[_i] = arguments[_i];
78
- }
79
- return function () {
80
- var args = [];
81
- for (var _i = 0; _i < arguments.length; _i++) {
82
- args[_i] = arguments[_i];
83
- }
84
- args[1] = wrapTestInZone(args[1]);
85
- return originalJestFn.apply(this, eachArgs).apply(this, args);
86
- };
59
+ const bindTest = (originalJestFn) => function (...eachArgs) {
60
+ return function (...args) {
61
+ args[1] = wrapTestInZone(args[1]);
62
+ return originalJestFn.apply(this, eachArgs).apply(this, args);
87
63
  };
88
64
  };
89
- ['xdescribe', 'fdescribe', 'describe'].forEach(function (methodName) {
90
- var originaljestFn = env[methodName];
91
- env[methodName] = function () {
92
- var args = [];
93
- for (var _i = 0; _i < arguments.length; _i++) {
94
- args[_i] = arguments[_i];
95
- }
65
+ ['xdescribe', 'fdescribe', 'describe'].forEach((methodName) => {
66
+ const originaljestFn = env[methodName];
67
+ env[methodName] = function (...args) {
96
68
  args[1] = wrapDescribeInZone(args[1]);
97
69
  return originaljestFn.apply(this, args);
98
70
  };
@@ -102,13 +74,9 @@ var bindTest = function (originalJestFn) {
102
74
  env[methodName].skip = env['xdescribe'];
103
75
  }
104
76
  });
105
- ['xit', 'fit', 'xtest', 'test', 'it'].forEach(function (methodName) {
106
- var originaljestFn = env[methodName];
107
- env[methodName] = function () {
108
- var args = [];
109
- for (var _i = 0; _i < arguments.length; _i++) {
110
- args[_i] = arguments[_i];
111
- }
77
+ ['xit', 'fit', 'xtest', 'test', 'it'].forEach((methodName) => {
78
+ const originaljestFn = env[methodName];
79
+ env[methodName] = function (...args) {
112
80
  args[1] = wrapTestInZone(args[1]);
113
81
  return originaljestFn.apply(this, args);
114
82
  };
@@ -116,22 +84,14 @@ var bindTest = function (originalJestFn) {
116
84
  if (methodName === 'test' || methodName === 'it') {
117
85
  env[methodName].only = env['fit'];
118
86
  env[methodName].skip = env['xit'];
119
- env[methodName].todo = function () {
120
- var args = [];
121
- for (var _i = 0; _i < arguments.length; _i++) {
122
- args[_i] = arguments[_i];
123
- }
87
+ env[methodName].todo = function (...args) {
124
88
  return originaljestFn.todo.apply(this, args);
125
89
  };
126
90
  }
127
91
  });
128
- ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) {
129
- var originaljestFn = env[methodName];
130
- env[methodName] = function () {
131
- var args = [];
132
- for (var _i = 0; _i < arguments.length; _i++) {
133
- args[_i] = arguments[_i];
134
- }
92
+ ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach((methodName) => {
93
+ const originaljestFn = env[methodName];
94
+ env[methodName] = function (...args) {
135
95
  args[0] = wrapTestInZone(args[0]);
136
96
  return originaljestFn.apply(this, args);
137
97
  };
package/index.js CHANGED
@@ -1 +1,8 @@
1
+ const { rootLogger } = require('ts-jest/dist/utils/logger');
2
+
3
+ rootLogger.warn(
4
+ "Import setup jest file via `import 'jest-preset-angular';` is deprecated and will be removed in v9.0.0." +
5
+ " Please switch to `import 'jest-preset-angular/setup-jest';`"
6
+ );
7
+
1
8
  module.exports = require('./build/setup-jest.js');
package/jest-preset.js CHANGED
@@ -23,8 +23,8 @@ module.exports = {
23
23
  },
24
24
  transformIgnorePatterns: ['node_modules/(?!@ngrx)'],
25
25
  snapshotSerializers: [
26
- 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
27
- 'jest-preset-angular/build/AngularSnapshotSerializer.js',
28
- 'jest-preset-angular/build/HTMLCommentSerializer.js',
26
+ 'jest-preset-angular/build/serializers/html-comment',
27
+ 'jest-preset-angular/build/serializers/ng-snapshot',
28
+ 'jest-preset-angular/build/serializers/no-ng-attributes',
29
29
  ],
30
30
  };
@@ -0,0 +1 @@
1
+ module.exports = require('./build/utils/ngcc-jest-processor');