Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit bdd91dd

Browse files
alan-agius4vikerman
authored andcommitted
test: add integration tests for hapi and express based on the schematics
1 parent cf78cf4 commit bdd91dd

File tree

140 files changed

+2871
-627
lines changed

Some content is hidden

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

140 files changed

+2871
-627
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# universal-integration
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.0-next.4.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"express-engine-ivy": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"inlineTemplate": true,
11+
"inlineStyle": true,
12+
"skipTests": true
13+
},
14+
"@schematics/angular:class": {
15+
"skipTests": true
16+
},
17+
"@schematics/angular:directive": {
18+
"skipTests": true
19+
},
20+
"@schematics/angular:guard": {
21+
"skipTests": true
22+
},
23+
"@schematics/angular:module": {
24+
"skipTests": true
25+
},
26+
"@schematics/angular:pipe": {
27+
"skipTests": true
28+
},
29+
"@schematics/angular:service": {
30+
"skipTests": true
31+
}
32+
},
33+
"root": "",
34+
"sourceRoot": "src",
35+
"prefix": "app",
36+
"architect": {
37+
"build": {
38+
"builder": "@angular-devkit/build-angular:browser",
39+
"options": {
40+
"progress": false,
41+
"outputPath": "dist/express-engine-ivy/browser",
42+
"index": "src/index.html",
43+
"main": "src/main.ts",
44+
"polyfills": "src/polyfills.ts",
45+
"tsConfig": "tsconfig.app.json",
46+
"aot": true,
47+
"assets": [
48+
"src/favicon.ico",
49+
"src/assets"
50+
],
51+
"styles": [
52+
"src/styles.css"
53+
],
54+
"scripts": []
55+
},
56+
"configurations": {
57+
"production": {
58+
"fileReplacements": [
59+
{
60+
"replace": "src/environments/environment.ts",
61+
"with": "src/environments/environment.prod.ts"
62+
}
63+
],
64+
"optimization": true,
65+
"outputHashing": "all",
66+
"sourceMap": false,
67+
"extractCss": true,
68+
"namedChunks": false,
69+
"extractLicenses": true,
70+
"vendorChunk": false,
71+
"buildOptimizer": true,
72+
"budgets": [
73+
{
74+
"type": "initial",
75+
"maximumWarning": "2mb",
76+
"maximumError": "5mb"
77+
},
78+
{
79+
"type": "anyComponentStyle",
80+
"maximumWarning": "6kb",
81+
"maximumError": "10kb"
82+
}
83+
]
84+
}
85+
}
86+
},
87+
"serve": {
88+
"builder": "@angular-devkit/build-angular:dev-server",
89+
"options": {
90+
"browserTarget": "express-engine-ivy:build"
91+
},
92+
"configurations": {
93+
"production": {
94+
"browserTarget": "express-engine-ivy:build:production"
95+
}
96+
}
97+
},
98+
"extract-i18n": {
99+
"builder": "@angular-devkit/build-angular:extract-i18n",
100+
"options": {
101+
"browserTarget": "express-engine-ivy:build"
102+
}
103+
},
104+
"test": {
105+
"builder": "@angular-devkit/build-angular:karma",
106+
"options": {
107+
"main": "src/test.ts",
108+
"polyfills": "src/polyfills.ts",
109+
"tsConfig": "tsconfig.spec.json",
110+
"karmaConfig": "karma.conf.js",
111+
"assets": [
112+
"src/favicon.ico",
113+
"src/assets"
114+
],
115+
"styles": [
116+
"src/styles.css"
117+
],
118+
"scripts": []
119+
}
120+
},
121+
"lint": {
122+
"builder": "@angular-devkit/build-angular:tslint",
123+
"options": {
124+
"tsConfig": [
125+
"tsconfig.app.json",
126+
"tsconfig.spec.json",
127+
"e2e/tsconfig.json"
128+
],
129+
"exclude": [
130+
"**/node_modules/**"
131+
]
132+
}
133+
},
134+
"e2e": {
135+
"builder": "@angular-devkit/build-angular:protractor",
136+
"options": {
137+
"protractorConfig": "e2e/protractor.conf.js"
138+
}
139+
},
140+
"server": {
141+
"builder": "@angular-devkit/build-angular:server",
142+
"options": {
143+
"progress": false,
144+
"outputPath": "dist/express-engine-ivy/server",
145+
"main": "server.ts",
146+
"tsConfig": "tsconfig.server.json"
147+
},
148+
"configurations": {
149+
"production": {
150+
"fileReplacements": [
151+
{
152+
"replace": "src/environments/environment.ts",
153+
"with": "src/environments/environment.prod.ts"
154+
}
155+
],
156+
"sourceMap": false,
157+
"optimization": {
158+
"scripts": false,
159+
"styles": true
160+
}
161+
}
162+
}
163+
}
164+
}
165+
}},
166+
"defaultProject": "express-engine-ivy"
167+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// @ts-check
2+
// Protractor configuration file, see link for more information
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
4+
5+
const { SpecReporter } = require('jasmine-spec-reporter');
6+
7+
/**
8+
* @type { import("protractor").Config }
9+
*/
10+
exports.config = {
11+
allScriptsTimeout: 11000,
12+
specs: [
13+
'./src/**/*.e2e-spec.ts'
14+
],
15+
capabilities: {
16+
browserName: 'chrome',
17+
chromeOptions: {
18+
args: ['--no-sandbox'],
19+
binary: process.env.CHROME_BIN,
20+
}
21+
},
22+
directConnect: true,
23+
baseUrl: 'http://localhost:4000/',
24+
framework: 'jasmine',
25+
jasmineNodeOpts: {
26+
showColors: true,
27+
defaultTimeoutInterval: 30000,
28+
print: function() {}
29+
},
30+
onPrepare() {
31+
require('ts-node').register({
32+
project: require('path').join(__dirname, './tsconfig.json')
33+
});
34+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
35+
}
36+
};

integration/express-engine/e2e/helloworld-spec.ts renamed to integration/express-engine-ivy/e2e/src/app.e2e-spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {browser, by, element} from 'protractor';
1010

1111
import {verifyNoBrowserErrors} from './util';
1212

13-
describe('Hello world E2E Tests', function() {
14-
it('should display: Hello world!', function() {
13+
describe('Hello world E2E Tests', () => {
14+
it('should display: Hello world!', () => {
1515
// Load the page without waiting for Angular since it is not bootstrapped automatically.
16-
browser.driver.get(browser.baseUrl + 'helloworld');
16+
browser.driver.get(browser.baseUrl);
1717

1818
const style = browser.driver.findElement(by.css('style[ng-transition="hlw"]'));
1919
expect(style.getText()).not.toBeNull();
@@ -35,13 +35,14 @@ describe('Hello world E2E Tests', function() {
3535
// Make sure there were no client side errors.
3636
verifyNoBrowserErrors();
3737
});
38+
3839
it('should populate window.location', () => {
3940
// Load the page without waiting for Angular since it is not bootstrapped automatically.
40-
browser.driver.get(browser.baseUrl + 'helloworld');
41+
browser.driver.get(browser.baseUrl);
4142

4243
// Test the contents from the server.
4344
const serverDiv = browser.driver.findElement(by.css('span.href-check'));
44-
expect(serverDiv.getText()).toMatch('http://localhost:9876/helloworld');
45+
expect(serverDiv.getText()).toMatch('http://localhost:4000');
4546

4647
// Make sure there were no client side errors.
4748
verifyNoBrowserErrors();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/e2e",
5+
"module": "commonjs",
6+
"target": "es5",
7+
"types": [
8+
"jasmine",
9+
"jasminewd2",
10+
"node"
11+
]
12+
}
13+
}
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/express-engine-ivy'),
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+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "universal-integration",
3+
"version": "0.0.0",
4+
"description": "Integration tests for @nguniversal",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/angular/universal.git"
8+
},
9+
"scripts": {
10+
"postinstall": "webdriver-manager update --gecko false --standalone false $CHROMEDRIVER_VERSION_ARG",
11+
"ng": "ng",
12+
"start": "ng serve",
13+
"e2e": "ng e2e",
14+
"test": "npm run build && npm run serve:test",
15+
"serve:test": "concurrently \"npm run serve:ssr\" \"npm run e2e\" --kill-others --success first",
16+
"serve:ssr": "node dist/express-engine-ivy/server/main.js",
17+
"build:ssr": "npm run build:client-and-server-bundles",
18+
"build": "ng build --prod && ng run express-engine-ivy:server:production"
19+
},
20+
"private": true,
21+
"dependencies": {
22+
"@angular/animations": "9.0.0-next.5",
23+
"@angular/common": "9.0.0-next.5",
24+
"@angular/compiler": "file:../../node_modules/@angular/compiler",
25+
"@angular/core": "file:../../node_modules/@angular/core",
26+
"@angular/forms": "9.0.0-next.5",
27+
"@angular/platform-browser": "9.0.0-next.5",
28+
"@angular/platform-browser-dynamic": "9.0.0-next.5",
29+
"@angular/platform-server": "9.0.0-next.5",
30+
"@angular/router": "9.0.0-next.5",
31+
"@nguniversal/express-engine": "file:../../dist/modules-dist/express-engine",
32+
"express": "file:../../node_modules/express",
33+
"rxjs": "file:../../node_modules/rxjs",
34+
"zone.js": "file:../../node_modules/zone.js"
35+
},
36+
"devDependencies": {
37+
"@angular-devkit/build-angular": "0.900.0-next.4",
38+
"@angular/cli": "9.0.0-next.4",
39+
"@angular/compiler-cli": "file:../../node_modules/@angular/compiler-cli",
40+
"@types/express": "file:../../node_modules/@types/express",
41+
"@types/node": "file:../../node_modules/@types/node",
42+
"@types/jasmine": "file:../../node_modules/@types/jasmine",
43+
"codelyzer": "5.1.0",
44+
"concurrently": "3.1.0",
45+
"jasmine-core": "3.4.0",
46+
"jasmine-spec-reporter": "4.2.1",
47+
"karma": "4.2.0",
48+
"karma-chrome-launcher": "3.1.0",
49+
"karma-coverage-istanbul-reporter": "2.1.0",
50+
"karma-jasmine": "2.0.1",
51+
"karma-jasmine-html-reporter": "1.4.2",
52+
"protractor": "file:../../node_modules/protractor",
53+
"ts-node": "8.3.0",
54+
"tslint": "5.18.0",
55+
"typescript": "file:../../node_modules/typescript"
56+
}
57+
}

0 commit comments

Comments
 (0)