Skip to content

Commit fe63308

Browse files
committed
fix: test
1 parent 9e4fab7 commit fe63308

41 files changed

Lines changed: 501 additions & 584 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

angular.json

Lines changed: 41 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,28 @@
44
"newProjectRoot": "projects",
55
"projects": {
66
"spec": {
7-
"root": "",
8-
"sourceRoot": "src",
97
"projectType": "application",
10-
"prefix": "app",
118
"schematics": {
129
"@schematics/angular:component": {
13-
"styleext": "scss",
14-
"spec": false
15-
},
16-
"@schematics/angular:class": {
17-
"spec": false
18-
},
19-
"@schematics/angular:directive": {
20-
"spec": false
21-
},
22-
"@schematics/angular:guard": {
23-
"spec": false
10+
"style": "scss"
2411
},
25-
"@schematics/angular:module": {
26-
"spec": false
27-
},
28-
"@schematics/angular:pipe": {
29-
"spec": false
30-
},
31-
"@schematics/angular:service": {
32-
"spec": false
12+
"@schematics/angular:application": {
13+
"strict": true
3314
}
3415
},
16+
"root": "",
17+
"sourceRoot": "src",
18+
"prefix": "app",
3519
"architect": {
3620
"build": {
3721
"builder": "@angular-devkit/build-angular:browser",
3822
"options": {
39-
"baseHref": "/",
40-
"deployUrl": "/",
41-
"outputPath": "./dist",
23+
"outputPath": "dist/spec",
4224
"index": "src/index.html",
4325
"main": "src/main.ts",
4426
"polyfills": "src/polyfills.ts",
45-
"tsConfig": "src/tsconfig.app.json",
27+
"tsConfig": "tsconfig.app.json",
28+
"aot": true,
4629
"assets": [
4730
"src/favicon.ico",
4831
"src/assets"
@@ -63,17 +46,26 @@
6346
"with": "src/environments/environment.prod.ts"
6447
}
6548
],
66-
"baseHref": "/",
67-
"deployUrl": "/",
6849
"optimization": true,
6950
"outputHashing": "all",
7051
"sourceMap": false,
7152
"extractCss": true,
7253
"namedChunks": false,
73-
"aot": true,
7454
"extractLicenses": true,
75-
"vendorChunk": true,
76-
"buildOptimizer": true
55+
"vendorChunk": false,
56+
"buildOptimizer": true,
57+
"budgets": [
58+
{
59+
"type": "initial",
60+
"maximumWarning": "500kb",
61+
"maximumError": "1mb"
62+
},
63+
{
64+
"type": "anyComponentStyle",
65+
"maximumWarning": "2kb",
66+
"maximumError": "4kb"
67+
}
68+
]
7769
}
7870
}
7971
},
@@ -97,58 +89,46 @@
9789
"test": {
9890
"builder": "@angular-devkit/build-angular:karma",
9991
"options": {
100-
"codeCoverage": true,
10192
"main": "src/test.ts",
10293
"polyfills": "src/polyfills.ts",
103-
"tsConfig": "src/tsconfig.spec.json",
104-
"karmaConfig": "src/karma.conf.js",
105-
"styles": [
106-
"src/styles.scss"
107-
],
108-
"scripts": [],
94+
"tsConfig": "tsconfig.spec.json",
95+
"karmaConfig": "karma.conf.js",
10996
"assets": [
11097
"src/favicon.ico",
11198
"src/assets"
112-
]
99+
],
100+
"styles": [
101+
"src/styles.scss"
102+
],
103+
"scripts": []
113104
}
114105
},
115106
"lint": {
116107
"builder": "@angular-devkit/build-angular:tslint",
117108
"options": {
118-
"fix": true,
119109
"tsConfig": [
120-
"src/tsconfig.app.json"
110+
"tsconfig.app.json",
111+
"tsconfig.spec.json",
112+
"e2e/tsconfig.json"
121113
],
122114
"exclude": [
123-
"**/node_modules/**",
124-
"**/src/polyfills.ts"
115+
"**/node_modules/**"
125116
]
126117
}
127-
}
128-
}
129-
},
130-
"spec-e2e": {
131-
"root": "e2e/",
132-
"projectType": "application",
133-
"architect": {
118+
},
134119
"e2e": {
135120
"builder": "@angular-devkit/build-angular:protractor",
136121
"options": {
137122
"protractorConfig": "e2e/protractor.conf.js",
138123
"devServerTarget": "spec:serve"
139-
}
140-
},
141-
"lint": {
142-
"builder": "@angular-devkit/build-angular:tslint",
143-
"options": {
144-
"tsConfig": "e2e/tsconfig.e2e.json",
145-
"exclude": [
146-
"**/node_modules/**"
147-
]
124+
},
125+
"configurations": {
126+
"production": {
127+
"devServerTarget": "spec:serve:production"
128+
}
148129
}
149130
}
150131
}
151-
}
152-
},
132+
}},
153133
"defaultProject": "spec"
154134
}

debug.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[1025/000400.296:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)

e2e/protractor.conf.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
1+
// @ts-check
12
// Protractor configuration file, see link for more information
23
// https://github.com/angular/protractor/blob/master/lib/config.ts
34

4-
const { SpecReporter } = require('jasmine-spec-reporter');
5+
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
56

7+
/**
8+
* @type { import("protractor").Config }
9+
*/
610
exports.config = {
711
allScriptsTimeout: 11000,
8-
specs: ['./src/**/*.e2e-spec.ts'],
12+
specs: [
13+
'./src/**/*.e2e-spec.ts'
14+
],
915
capabilities: {
10-
browserName: 'chrome',
16+
browserName: 'chrome'
1117
},
1218
directConnect: true,
1319
baseUrl: 'http://localhost:4200/',
1420
framework: 'jasmine',
1521
jasmineNodeOpts: {
1622
showColors: true,
1723
defaultTimeoutInterval: 30000,
18-
print: function() {},
24+
print: function() {}
1925
},
2026
onPrepare() {
2127
require('ts-node').register({
22-
project: require('path').join(__dirname, './tsconfig.e2e.json'),
28+
project: require('path').join(__dirname, './tsconfig.json')
2329
});
24-
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
25-
},
26-
};
30+
jasmine.getEnv().addReporter(new SpecReporter({
31+
spec: {
32+
displayStacktrace: StacktraceOption.PRETTY
33+
}
34+
}));
35+
}
36+
};

e2e/src/app.e2e-spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AppPage } from './app.po';
2+
import { browser, logging } from 'protractor';
23

34
describe('workspace-project App', () => {
45
let page: AppPage;
@@ -7,10 +8,16 @@ describe('workspace-project App', () => {
78
page = new AppPage();
89
});
910

10-
it('should display correct title', () => {
11+
it('should display welcome message', () => {
1112
page.navigateTo();
12-
expect(page.getParagraphText())
13-
.toEqual('MPGP Documentation')
14-
.catch(e => console.error(e));
13+
expect(page.getParagraphText()).toEqual('MPGP Documentation');
14+
});
15+
16+
afterEach(async () => {
17+
// Assert that there are no errors emitted from the browser
18+
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19+
expect(logs).not.toContain(jasmine.objectContaining({
20+
level: logging.Level.SEVERE,
21+
} as logging.Entry));
1522
});
1623
});

e2e/src/app.po.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// tslint:disable: no-any
21
import { browser, by, element } from 'protractor';
32

43
export class AppPage {
5-
navigateTo(): any {
6-
return browser.get('/');
4+
navigateTo(): Promise<unknown> {
5+
return browser.get(browser.baseUrl) as Promise<unknown>;
76
}
87

9-
getParagraphText(): any {
10-
return element(by.css('main-root > mat-sidenav-container > mat-sidenav-content > main-sidenav-content > mat-toolbar > span')).getText();
8+
getParagraphText(): Promise<string> {
9+
const selector = 'main-root > mat-sidenav-container > mat-sidenav-content > main-sidenav-content > mat-toolbar > span';
10+
11+
return element(by.css(selector)).getText() as Promise<string>;
1112
}
1213
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
12
{
23
"extends": "../tsconfig.json",
34
"compilerOptions": {
4-
"outDir": "../out-tsc/app",
5+
"outDir": "../out-tsc/e2e",
56
"module": "commonjs",
6-
"target": "es5",
7+
"target": "es2018",
78
"types": [
89
"jasmine",
910
"jasminewd2",
1011
"node"
1112
]
1213
}
13-
}
14+
}

karma.conf.js

Lines changed: 32 additions & 0 deletions
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/spec'),
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: false,
30+
restartOnFileChange: true
31+
});
32+
};

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@
109109
"start": "ng serve",
110110
"static": "static ./dist",
111111
"test": "echo Please use yarn run test:unit",
112-
"test:unit": "CHROME_BIN=google-chrome CHROME_CANARY_BIN=google-chrome ng test --watch=false --code-coverage",
113-
"test:e2e": "CHROME_BIN=google-chrome CHROME_CANARY_BIN=google-chrome ng e2e",
114-
"ci:test": "CHROME_BIN=chromium-browser DISPLAY=:99.0 ng test --watch=false --code-coverage",
115-
"ci:e2e": "CHROME_BIN=chromium-browser DISPLAY=:99.0 ng e2e"
112+
"test:unit": "ng test",
113+
"ci:test": "ng test --watch=false --code-coverage",
114+
"ci:e2e": "ng e2e"
116115
},
117116
"dependencies": {
118117
"@angular/animations": "10.2.0",

scripts/ci/4_script.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
COMMANDS_TO_RUN+=('echo 4_script.sh ...')
22
COMMANDS_TO_RUN+=('echo run tests')
3-
#COMMANDS_TO_RUN+=('yarn run ci:e2e')
4-
#COMMANDS_TO_RUN+=('yarn run ci:test')
5-
#COMMANDS_TO_RUN+=('echo Generate coverage info and deploy it to coveralls.io')
6-
#COMMANDS_TO_RUN+=('cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js')
3+
COMMANDS_TO_RUN+=('yarn run ci:e2e')
4+
COMMANDS_TO_RUN+=('yarn run ci:test')
5+
COMMANDS_TO_RUN+=('echo Generate coverage info and deploy it to coveralls.io')
6+
COMMANDS_TO_RUN+=('cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js')

0 commit comments

Comments
 (0)