-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stark-testing): replace
karma-typescript
by karma
+ `@angula…
…r/devkit:build-angular` Increase test speed thanks to karma + stop use "commonjs" module during test. BREAKING CHANGE: Adapt angular.json, package.json and base.spec.ts files. Check test config in "angular.json": ``` // ... "test": { "builder": "@angular-builders/custom-webpack:karma", "options": { "main": "base.spec.ts", "karmaConfig": "./karma.conf.js", "tsConfig": "tsconfig.spec.json" } } ``` Check tests scripts in "package.json": ``` // BEFORE "test-fast": "karma start", "test-fast:ci": "karma start karma.conf.ci.js", // AFTER "test-fast": "npm run ng test", "test-fast:ci": "cross-env CI=1 npm run ng test --code-coverage", ``` Adapt "base.spec.ts" file as follows: ```typescript "use strict"; import "core-js/es"; import "core-js/proposals/reflect-metadata"; // IE polyfills // See https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill /* tslint:disable:no-unbound-method */ if (!Element.prototype.matches) { Element.prototype.matches = (<any>Element.prototype).msMatchesSelector || Element.prototype.webkitMatchesSelector; } /* tslint:enable:no-unbound-method */ // See: https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill if ((<any>window).NodeList && !NodeList.prototype.forEach) { (<any>NodeList.prototype).forEach = Array.prototype.forEach; } /* tslint:disable:no-import-side-effect */ import "zone.js/dist/zone"; import "zone.js/dist/zone-testing"; import "zone.js/dist/long-stack-trace-zone"; /* tslint:enable:no-import-side-effect */ // define global environment variable (used in some places in stark-core and stark-ui) global["ENV"] = "development"; import { getTestBed } from "@angular/core/testing"; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from "@angular/platform-browser-dynamic/testing"; // tslint:disable:completed-docs bool-param-default declare const require: { context(path: string, deep?: boolean, filter?: RegExp): { keys(): string[]; <T>(id: string): T; }; }; getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); // Then we find all the tests. const context = require.context('./src', true, /\.spec\.ts$/); // And load the modules. context.keys().forEach(context); ```
- Loading branch information
1 parent
c13709f
commit a9e06dc
Showing
20 changed files
with
4,577 additions
and
2,279 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
}, | ||
"files": null, | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
}, | ||
"files": null, | ||
"include": ["**/*.ts"] | ||
} |
Oops, something went wrong.