Skip to content

Commit 6e4a00a

Browse files
committed
Add dummy "all" project to test all projects at once in one browser
1 parent bdfc2bf commit 6e4a00a

File tree

6 files changed

+150
-1
lines changed

6 files changed

+150
-1
lines changed

angular.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {
6+
"all": {
7+
"root": "./",
8+
"projectType": "application",
9+
"architect": {
10+
"test": {
11+
"builder": "@angular-devkit/build-angular:karma",
12+
"options": {
13+
"main": "./test.ts",
14+
"polyfills": "./polyfills.ts",
15+
"tsConfig": "./tsconfig.spec.json",
16+
"karmaConfig": "./karma.conf.js"
17+
}
18+
}
19+
}
20+
},
621
"ng-test-all": {
722
"root": "",
823
"sourceRoot": "src",
@@ -207,4 +222,4 @@
207222
}
208223
},
209224
"defaultProject": "ng-test-all"
210-
}
225+
}

karma.conf.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
18+
coverageIstanbulReporter: {
19+
dir: require('path').join(__dirname, './coverage/ng-test-all'),
20+
reports: ['html', 'lcovonly', 'text-summary'],
21+
fixWebpackSourcePaths: true
22+
},
23+
reporters: ['progress', 'kjhtml'],
24+
port: 9876,
25+
colors: true,
26+
logLevel: config.LOG_INFO,
27+
autoWatch: true,
28+
browsers: ['Chrome'],
29+
singleRun: true,
30+
restartOnFileChange: true
31+
});
32+
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"start": "ng serve",
77
"build": "ng build",
88
"test": "ng test",
9+
"test:all": "ng test all",
910
"lint": "ng lint",
1011
"e2e": "ng e2e"
1112
},

polyfills.ts

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 Safari >= 10, Chrome >= 55 (including Opera),
12+
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13+
*
14+
* Learn more in https://angular.io/guide/browser-support
15+
*/
16+
17+
/***************************************************************************************************
18+
* BROWSER POLYFILLS
19+
*/
20+
21+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
22+
// import 'classlist.js'; // Run `npm install --save classlist.js`.
23+
24+
/**
25+
* Web Animations `@angular/platform-browser/animations`
26+
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27+
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28+
*/
29+
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30+
31+
/**
32+
* By default, zone.js will patch all possible macroTask and DomEvents
33+
* user can disable parts of macroTask/DomEvents patch by setting following flags
34+
* because those flags need to be set before `zone.js` being loaded, and webpack
35+
* will put import in the top of bundle, so user need to create a separate file
36+
* in this directory (for example: zone-flags.ts), and put the following flags
37+
* into that file, and then add the following code before importing zone.js.
38+
* import './zone-flags.ts';
39+
*
40+
* The flags allowed in zone-flags.ts are listed here.
41+
*
42+
* The following flags will work for all browsers.
43+
*
44+
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45+
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46+
* (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47+
*
48+
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49+
* with the following flag, it will bypass `zone.js` patch for IE/Edge
50+
*
51+
* (window as any).__Zone_enable_cross_context_check = true;
52+
*
53+
*/
54+
55+
/***************************************************************************************************
56+
* Zone JS is required by default for Angular itself.
57+
*/
58+
import 'zone.js/dist/zone'; // Included with Angular CLI.
59+
60+
61+
/***************************************************************************************************
62+
* APPLICATION IMPORTS
63+
*/

test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
2+
3+
import 'zone.js/dist/zone-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: any;
11+
12+
// First, initialize the Angular testing environment.
13+
getTestBed().initTestEnvironment(
14+
BrowserDynamicTestingModule,
15+
platformBrowserDynamicTesting()
16+
);
17+
// Then we find all the tests.
18+
const context = require.context('./', true, /^\.\/(src|projects)\/.+\.spec\.ts$/);
19+
// And load the modules.
20+
context.keys().map(context);

tsconfig.spec.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/spec",
5+
"types": [
6+
"jasmine",
7+
"node"
8+
]
9+
},
10+
"files": [
11+
"test.ts",
12+
"polyfills.ts"
13+
],
14+
"include": [
15+
"**/*.spec.ts",
16+
"**/*.d.ts"
17+
]
18+
}

0 commit comments

Comments
 (0)