@schematics/angular 15.0.0-next.2 → 15.0.0-next.3

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,12 +1,8 @@
1
- import { enableProdMode<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';
1
+ <% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';<% }%>
2
2
  import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3
3
 
4
4
  import { AppModule } from './app/app.module';
5
- import { environment } from './environments/environment';
6
5
 
7
- if (environment.production) {
8
- enableProdMode();
9
- }
10
6
  <% if(!!viewEncapsulation) { %>
11
7
  platformBrowserDynamic().bootstrapModule(AppModule, {
12
8
  defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %>
@@ -15,4 +11,4 @@ platformBrowserDynamic().bootstrapModule(AppModule, {
15
11
  <% } else { %>
16
12
  platformBrowserDynamic().bootstrapModule(AppModule)
17
13
  .catch(err => console.error(err));
18
- <% } %>
14
+ <% } %>
@@ -6,8 +6,7 @@
6
6
  "types": []
7
7
  },
8
8
  "files": [
9
- "src/main.ts",
10
- "src/polyfills.ts"
9
+ "src/main.ts"
11
10
  ],
12
11
  "include": [
13
12
  "src/**/*.d.ts"
@@ -7,10 +7,6 @@
7
7
  "jasmine"
8
8
  ]
9
9
  },
10
- "files": [
11
- "src/test.ts",
12
- "src/polyfills.ts"
13
- ],
14
10
  "include": [
15
11
  "src/**/*.spec.ts",
16
12
  "src/**/*.d.ts"
@@ -127,7 +127,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
127
127
  outputPath: `dist/${folderName}`,
128
128
  index: `${sourceRoot}/index.html`,
129
129
  main: `${sourceRoot}/main.ts`,
130
- polyfills: `${sourceRoot}/polyfills.ts`,
130
+ polyfills: ['zone.js'],
131
131
  tsConfig: `${projectRoot}tsconfig.app.json`,
132
132
  inlineStyleLanguage,
133
133
  assets: [`${sourceRoot}/favicon.ico`, `${sourceRoot}/assets`],
@@ -137,12 +137,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
137
137
  configurations: {
138
138
  production: {
139
139
  budgets,
140
- fileReplacements: [
141
- {
142
- replace: `${sourceRoot}/environments/environment.ts`,
143
- with: `${sourceRoot}/environments/environment.prod.ts`,
144
- },
145
- ],
146
140
  outputHashing: 'all',
147
141
  },
148
142
  development: {
@@ -179,8 +173,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
179
173
  : {
180
174
  builder: workspace_models_1.Builders.Karma,
181
175
  options: {
182
- main: `${sourceRoot}/test.ts`,
183
- polyfills: `${sourceRoot}/polyfills.ts`,
176
+ polyfills: ['zone.js', 'zone.js/testing'],
184
177
  tsConfig: `${projectRoot}tsconfig.spec.json`,
185
178
  karmaConfig: `${projectRoot}karma.conf.js`,
186
179
  inlineStyleLanguage,
@@ -199,7 +192,7 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
199
192
  });
200
193
  }
201
194
  function minimalPathFilter(path) {
202
- const toRemoveList = /(test.ts|tsconfig.spec.json|karma.conf.js).template$/;
195
+ const toRemoveList = /(tsconfig.spec.json|karma.conf.js).template$/;
203
196
  return !toRemoveList.test(path);
204
197
  }
205
198
  function default_1(options) {
@@ -9,7 +9,6 @@
9
9
  "types": []
10
10
  },
11
11
  "exclude": [
12
- "src/test.ts",
13
12
  "**/*.spec.ts"
14
13
  ]
15
14
  }
@@ -7,9 +7,6 @@
7
7
  "jasmine"
8
8
  ]
9
9
  },
10
- "files": [
11
- "src/test.ts"
12
- ],
13
10
  "include": [
14
11
  "**/*.spec.ts",
15
12
  "**/*.d.ts"
package/library/index.js CHANGED
@@ -86,8 +86,8 @@ function addLibToWorkspaceFile(options, projectRoot, projectName) {
86
86
  test: {
87
87
  builder: workspace_models_1.Builders.Karma,
88
88
  options: {
89
- main: `${projectRoot}/src/test.ts`,
90
89
  tsConfig: `${projectRoot}/tsconfig.spec.json`,
90
+ polyfills: ['zone.js', 'zone.js/testing'],
91
91
  karmaConfig: `${projectRoot}/karma.conf.js`,
92
92
  },
93
93
  },
@@ -14,6 +14,16 @@
14
14
  "version": "15.0.0",
15
15
  "factory": "./update-15/update-typescript-target",
16
16
  "description": "Update TypeScript compiler `target` and set `useDefineForClassFields`. These changes are for IDE purposes as TypeScript compiler options `target` and `useDefineForClassFields` are set to `ES2022` and `false` respectively by the Angular CLI. To control ECMA version and features use the Browerslist configuration."
17
+ },
18
+ "update-workspace-config": {
19
+ "version": "15.0.0",
20
+ "factory": "./update-15/update-workspace-config",
21
+ "description": "Remove options from 'angular.json' that are no longer supported by the official builders."
22
+ },
23
+ "update-karma-main-file": {
24
+ "version": "15.0.0",
25
+ "factory": "./update-15/update-karma-main-file",
26
+ "description": "Remove no longer needed require calls in Karma builder main file."
17
27
  }
18
28
  }
19
29
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;
@@ -0,0 +1,106 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
34
+ const utility_1 = require("../../utility");
35
+ const workspace_1 = require("../../utility/workspace");
36
+ const workspace_models_1 = require("../../utility/workspace-models");
37
+ function default_1() {
38
+ return async (host) => {
39
+ for (const file of await findTestMainFiles(host)) {
40
+ updateTestFile(host, file);
41
+ }
42
+ };
43
+ }
44
+ exports.default = default_1;
45
+ async function findTestMainFiles(host) {
46
+ const testFiles = new Set();
47
+ const workspace = await (0, utility_1.readWorkspace)(host);
48
+ // find all test.ts files.
49
+ for (const project of workspace.projects.values()) {
50
+ for (const target of project.targets.values()) {
51
+ if (target.builder !== workspace_models_1.Builders.Karma) {
52
+ continue;
53
+ }
54
+ for (const [, options] of (0, workspace_1.allTargetOptions)(target)) {
55
+ if (typeof options.main === 'string') {
56
+ testFiles.add(options.main);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return testFiles;
62
+ }
63
+ function updateTestFile(host, file) {
64
+ const content = host.readText(file);
65
+ if (!content.includes('require.context')) {
66
+ return;
67
+ }
68
+ const sourceFile = ts.createSourceFile(file, content.replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
69
+ const usedVariableNames = new Set();
70
+ const recorder = host.beginUpdate(sourceFile.fileName);
71
+ ts.forEachChild(sourceFile, (node) => {
72
+ var _a, _b;
73
+ if (ts.isVariableStatement(node)) {
74
+ const variableDeclaration = node.declarationList.declarations[0];
75
+ if ((_a = ts.getModifiers(node)) === null || _a === void 0 ? void 0 : _a.some((m) => m.kind === ts.SyntaxKind.DeclareKeyword)) {
76
+ // `declare const require`
77
+ if (variableDeclaration.name.getText() !== 'require') {
78
+ return;
79
+ }
80
+ }
81
+ else {
82
+ // `const context = require.context('./', true, /\.spec\.ts$/);`
83
+ if (!((_b = variableDeclaration.initializer) === null || _b === void 0 ? void 0 : _b.getText().startsWith('require.context'))) {
84
+ return;
85
+ }
86
+ // add variable name as used.
87
+ usedVariableNames.add(variableDeclaration.name.getText());
88
+ }
89
+ // Delete node.
90
+ recorder.remove(node.getFullStart(), node.getFullWidth());
91
+ }
92
+ if (usedVariableNames.size &&
93
+ ts.isExpressionStatement(node) && // context.keys().map(context);
94
+ ts.isCallExpression(node.expression) && // context.keys().map(context);
95
+ ts.isPropertyAccessExpression(node.expression.expression) && // context.keys().map
96
+ ts.isCallExpression(node.expression.expression.expression) && // context.keys()
97
+ ts.isPropertyAccessExpression(node.expression.expression.expression.expression) && // context.keys
98
+ ts.isIdentifier(node.expression.expression.expression.expression.expression) && // context
99
+ usedVariableNames.has(node.expression.expression.expression.expression.expression.getText())) {
100
+ // `context.keys().map(context);`
101
+ // `context.keys().forEach(context);`
102
+ recorder.remove(node.getFullStart(), node.getFullWidth());
103
+ }
104
+ });
105
+ host.commitUpdate(recorder);
106
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;
@@ -0,0 +1,26 @@
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
+ const workspace_1 = require("../../utility/workspace");
11
+ const workspace_models_1 = require("../../utility/workspace-models");
12
+ function default_1() {
13
+ return (0, workspace_1.updateWorkspace)((workspace) => {
14
+ for (const project of workspace.projects.values()) {
15
+ for (const target of project.targets.values()) {
16
+ if (target.builder !== workspace_models_1.Builders.Server) {
17
+ continue;
18
+ }
19
+ for (const [, options] of (0, workspace_1.allTargetOptions)(target)) {
20
+ delete options.bundleDependencies;
21
+ }
22
+ }
23
+ }
24
+ });
25
+ }
26
+ exports.default = default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "15.0.0-next.2",
3
+ "version": "15.0.0-next.3",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "15.0.0-next.2",
27
- "@angular-devkit/schematics": "15.0.0-next.2",
26
+ "@angular-devkit/core": "15.0.0-next.3",
27
+ "@angular-devkit/schematics": "15.0.0-next.3",
28
28
  "jsonc-parser": "3.2.0"
29
29
  },
30
30
  "repository": {
@@ -62,47 +62,18 @@ function updateAppModule(mainPath) {
62
62
  context.logger.debug('Updating appmodule');
63
63
  const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
64
64
  context.logger.debug(`module path: ${modulePath}`);
65
- // add import
66
- let moduleSource = getTsSourceFile(host, modulePath);
67
- let importModule = 'ServiceWorkerModule';
68
- let importPath = '@angular/service-worker';
69
- if (!(0, ast_utils_1.isImported)(moduleSource, importModule, importPath)) {
70
- const change = (0, ast_utils_1.insertImport)(moduleSource, modulePath, importModule, importPath);
71
- if (change) {
72
- const recorder = host.beginUpdate(modulePath);
73
- (0, change_1.applyToUpdateRecorder)(recorder, [change]);
74
- host.commitUpdate(recorder);
75
- }
76
- }
77
- // add import for environments
78
- // import { environment } from '../environments/environment';
79
- moduleSource = getTsSourceFile(host, modulePath);
80
- const environmentExportName = (0, ast_utils_1.getEnvironmentExportName)(moduleSource);
81
- // if environemnt import already exists then use the found one
82
- // otherwise use the default name
83
- importModule = environmentExportName || 'environment';
84
- // TODO: dynamically find environments relative path
85
- importPath = '../environments/environment';
86
- if (!environmentExportName) {
87
- // if environment import was not found then insert the new one
88
- // with default path and default export name
89
- const change = (0, ast_utils_1.insertImport)(moduleSource, modulePath, importModule, importPath);
90
- if (change) {
91
- const recorder = host.beginUpdate(modulePath);
92
- (0, change_1.applyToUpdateRecorder)(recorder, [change]);
93
- host.commitUpdate(recorder);
94
- }
95
- }
65
+ addImport(host, modulePath, 'ServiceWorkerModule', '@angular/service-worker');
66
+ addImport(host, modulePath, 'isDevMode', '@angular/core');
96
67
  // register SW in application module
97
68
  const importText = core_1.tags.stripIndent `
98
69
  ServiceWorkerModule.register('ngsw-worker.js', {
99
- enabled: ${importModule}.production,
70
+ enabled: !isDevMode(),
100
71
  // Register the ServiceWorker as soon as the application is stable
101
72
  // or after 30 seconds (whichever comes first).
102
73
  registrationStrategy: 'registerWhenStable:30000'
103
74
  })
104
75
  `;
105
- moduleSource = getTsSourceFile(host, modulePath);
76
+ const moduleSource = getTsSourceFile(host, modulePath);
106
77
  const metadataChanges = (0, ast_utils_1.addSymbolToNgModuleMetadata)(moduleSource, modulePath, 'imports', importText);
107
78
  if (metadataChanges) {
108
79
  const recorder = host.beginUpdate(modulePath);
@@ -157,3 +128,12 @@ function default_1(options) {
157
128
  };
158
129
  }
159
130
  exports.default = default_1;
131
+ function addImport(host, filePath, symbolName, moduleName) {
132
+ const moduleSource = getTsSourceFile(host, filePath);
133
+ const change = (0, ast_utils_1.insertImport)(moduleSource, filePath, symbolName, moduleName);
134
+ if (change) {
135
+ const recorder = host.beginUpdate(filePath);
136
+ (0, change_1.applyToUpdateRecorder)(recorder, [change]);
137
+ host.commitUpdate(recorder);
138
+ }
139
+ }
@@ -12,12 +12,5 @@ import '@angular/platform-server/init';
12
12
  */
13
13
  import '@angular/localize/init';
14
14
 
15
- <% } %>import { enableProdMode } from '@angular/core';
16
-
17
- import { environment } from './environments/environment';
18
-
19
- if (environment.production) {
20
- enableProdMode();
21
- }
22
-
15
+ <% } %>
23
16
  export { <%= rootModuleClassName %> } from './app/<%= stripTsExtension(rootModuleFileName) %>';
@@ -86,12 +86,6 @@ export declare function addBootstrapToModule(source: ts.SourceFile, modulePath:
86
86
  * Determine if an import already exists.
87
87
  */
88
88
  export declare function isImported(source: ts.SourceFile, classifiedName: string, importPath: string): boolean;
89
- /**
90
- * This function returns the name of the environment export
91
- * whether this export is aliased or not. If the environment file
92
- * is not imported, then it will return `null`.
93
- */
94
- export declare function getEnvironmentExportName(source: ts.SourceFile): string | null;
95
89
  /**
96
90
  * Returns the RouterModule declaration from NgModule metadata, if any.
97
91
  */
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.addRouteDeclarationToModule = exports.getRouterModuleDeclaration = exports.getEnvironmentExportName = exports.isImported = exports.addBootstrapToModule = exports.addExportToModule = exports.addProviderToModule = exports.addImportToModule = exports.addDeclarationToModule = exports.addSymbolToNgModuleMetadata = exports.getMetadataField = exports.getDecoratorMetadata = exports.insertAfterLastOccurrence = exports.findNode = exports.getSourceNodes = exports.findNodes = exports.insertImport = void 0;
33
+ exports.addRouteDeclarationToModule = exports.getRouterModuleDeclaration = exports.isImported = exports.addBootstrapToModule = exports.addExportToModule = exports.addProviderToModule = exports.addImportToModule = exports.addDeclarationToModule = exports.addSymbolToNgModuleMetadata = exports.getMetadataField = exports.getDecoratorMetadata = exports.insertAfterLastOccurrence = exports.findNode = exports.getSourceNodes = exports.findNodes = exports.insertImport = void 0;
34
34
  const core_1 = require("@angular-devkit/core");
35
35
  const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
36
36
  const change_1 = require("./change");
@@ -423,43 +423,6 @@ function isImported(source, classifiedName, importPath) {
423
423
  return matchingNodes.length > 0;
424
424
  }
425
425
  exports.isImported = isImported;
426
- /**
427
- * This function returns the name of the environment export
428
- * whether this export is aliased or not. If the environment file
429
- * is not imported, then it will return `null`.
430
- */
431
- function getEnvironmentExportName(source) {
432
- // Initial value is `null` as we don't know yet if the user
433
- // has imported `environment` into the root module or not.
434
- let environmentExportName = null;
435
- const allNodes = getSourceNodes(source);
436
- allNodes
437
- .filter(ts.isImportDeclaration)
438
- .filter((declaration) => declaration.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral &&
439
- declaration.importClause !== undefined)
440
- .map((declaration) =>
441
- // If `importClause` property is defined then the first
442
- // child will be `NamedImports` object (or `namedBindings`).
443
- declaration.importClause.getChildAt(0))
444
- // Find those `NamedImports` object that contains `environment` keyword
445
- // in its text. E.g. `{ environment as env }`.
446
- .filter(ts.isNamedImports)
447
- .filter((namedImports) => namedImports.getText().includes('environment'))
448
- .forEach((namedImports) => {
449
- for (const specifier of namedImports.elements) {
450
- // `propertyName` is defined if the specifier
451
- // has an aliased import.
452
- const name = specifier.propertyName || specifier.name;
453
- // Find specifier that contains `environment` keyword in its text.
454
- // Whether it's `environment` or `environment as env`.
455
- if (name.text.includes('environment')) {
456
- environmentExportName = specifier.name.text;
457
- }
458
- }
459
- });
460
- return environmentExportName;
461
- }
462
- exports.getEnvironmentExportName = getEnvironmentExportName;
463
426
  /**
464
427
  * Returns the RouterModule declaration from NgModule metadata, if any.
465
428
  */
@@ -1,3 +0,0 @@
1
- export const environment = {
2
- production: true
3
- };
@@ -1,16 +0,0 @@
1
- // This file can be replaced during build by using the `fileReplacements` array.
2
- // `ng build` replaces `environment.ts` with `environment.prod.ts`.
3
- // The list of file replacements can be found in `angular.json`.
4
-
5
- export const environment = {
6
- production: false
7
- };
8
-
9
- /*
10
- * For easier debugging in development mode, you can import the following file
11
- * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12
- *
13
- * This import should be commented out in production mode because it will have a negative impact
14
- * on performance if an error is thrown.
15
- */
16
- // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
@@ -1,53 +0,0 @@
1
- /**
2
- * This file includes polyfills needed by Angular and is loaded before the app.
3
- * You can add your own extra polyfills to this file.
4
- *
5
- * This file is divided into 2 sections:
6
- * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7
- * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8
- * file.
9
- *
10
- * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11
- * automatically update themselves. This includes recent versions of Safari, Chrome (including
12
- * Opera), Edge on the desktop, and iOS and Chrome on mobile.
13
- *
14
- * Learn more in https://angular.io/guide/browser-support
15
- */
16
-
17
- /***************************************************************************************************
18
- * BROWSER POLYFILLS
19
- */
20
-
21
- /**
22
- * By default, zone.js will patch all possible macroTask and DomEvents
23
- * user can disable parts of macroTask/DomEvents patch by setting following flags
24
- * because those flags need to be set before `zone.js` being loaded, and webpack
25
- * will put import in the top of bundle, so user need to create a separate file
26
- * in this directory (for example: zone-flags.ts), and put the following flags
27
- * into that file, and then add the following code before importing zone.js.
28
- * import './zone-flags';
29
- *
30
- * The flags allowed in zone-flags.ts are listed here.
31
- *
32
- * The following flags will work for all browsers.
33
- *
34
- * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
35
- * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
36
- * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
37
- *
38
- * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
39
- * with the following flag, it will bypass `zone.js` patch for IE/Edge
40
- *
41
- * (window as any).__Zone_enable_cross_context_check = true;
42
- *
43
- */
44
-
45
- /***************************************************************************************************
46
- * Zone JS is required by default for Angular itself.
47
- */
48
- import 'zone.js'; // Included with Angular CLI.
49
-
50
-
51
- /***************************************************************************************************
52
- * APPLICATION IMPORTS
53
- */
@@ -1,26 +0,0 @@
1
- // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
-
3
- import 'zone.js/testing';
4
- import { getTestBed } from '@angular/core/testing';
5
- import {
6
- BrowserDynamicTestingModule,
7
- platformBrowserDynamicTesting
8
- } from '@angular/platform-browser-dynamic/testing';
9
-
10
- declare const require: {
11
- context(path: string, deep?: boolean, filter?: RegExp): {
12
- <T>(id: string): T;
13
- keys(): string[];
14
- };
15
- };
16
-
17
- // First, initialize the Angular testing environment.
18
- getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
19
- errorOnUnknownElements: true,
20
- errorOnUnknownProperties: true
21
- });
22
-
23
- // Then we find all the tests.
24
- const context = require.context('./', true, /\.spec\.ts$/);
25
- // And load the modules.
26
- context.keys().forEach(context);
@@ -1,27 +0,0 @@
1
- // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
-
3
- import 'zone.js';
4
- import 'zone.js/testing';
5
- import { getTestBed } from '@angular/core/testing';
6
- import {
7
- BrowserDynamicTestingModule,
8
- platformBrowserDynamicTesting
9
- } from '@angular/platform-browser-dynamic/testing';
10
-
11
- declare const require: {
12
- context(path: string, deep?: boolean, filter?: RegExp): {
13
- <T>(id: string): T;
14
- keys(): string[];
15
- };
16
- };
17
-
18
- // First, initialize the Angular testing environment.
19
- getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
20
- errorOnUnknownElements: true,
21
- errorOnUnknownProperties: true
22
- });
23
-
24
- // Then we find all the tests.
25
- const context = require.context('./', true, /\.spec\.ts$/);
26
- // And load the modules.
27
- context.keys().forEach(context);