Skip to content

Commit fb6b50c

Browse files
devversionmmalerba
authored andcommitted
test: setup minimal cli project as integration test for harness
We do not have any integration tests for the harness usage in e2e test runners/setups like Cypress, selenium-webdriver etc. This is a foundation for adding this in the future.
1 parent bc2aac8 commit fb6b50c

26 files changed

+7009
-0
lines changed

.bazelignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
node_modules
22

3+
integration/harness-e2e-cli/.angular
4+
integration/harness-e2e-cli/node_modules
5+
36
integration/ng-update-v13/.angular
47
integration/ng-update-v13/node_modules
58

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
.history/*
32+
33+
# misc
34+
/.angular/cache
35+
/.sass-cache
36+
/connect.lock
37+
/coverage
38+
/libpeerconnection.log
39+
npm-debug.log
40+
yarn-error.log
41+
testem.log
42+
/typings
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
load("@bazel_skylib//lib:dicts.bzl", "dicts")
2+
load("//tools:integration.bzl", "CLI_PROJECT_MAPPINGS")
3+
load("//tools:defaults.bzl", "node_integration_test")
4+
5+
npmPackageMappings = dicts.add(
6+
CLI_PROJECT_MAPPINGS,
7+
{
8+
"//src/cdk:npm_package_archive": "@angular/cdk",
9+
"//src/material:npm_package_archive": "@angular/material",
10+
},
11+
)
12+
13+
node_integration_test(
14+
name = "test",
15+
srcs = glob(["**/*"]),
16+
commands = [
17+
# Note: We use a cache folder within the integration test as otherwise
18+
# the NPM package mapped archive would be cached in the system.
19+
# See: https://github.com/yarnpkg/yarn/issues/2165.
20+
# TODO(devversion): determine if a solution/workaround could live in the test runner.
21+
"yarn install --cache-folder .yarn_cache_folder/",
22+
"yarn e2e",
23+
],
24+
npm_packages = npmPackageMappings,
25+
setup_chromium = True,
26+
tags = [
27+
# This test relies on `yarn` so there needs to be internet access.
28+
"requires-network",
29+
],
30+
)

integration/harness-e2e-cli/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# HarnessE2eCli
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0-next.1.
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.
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 a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"harness-e2e-cli": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "scss"
11+
},
12+
"@schematics/angular:application": {
13+
"strict": true
14+
}
15+
},
16+
"root": "",
17+
"sourceRoot": "src",
18+
"prefix": "app",
19+
"architect": {
20+
"build": {
21+
"builder": "@angular-devkit/build-angular:browser",
22+
"options": {
23+
"outputPath": "dist/harness-e2e-cli",
24+
"index": "src/index.html",
25+
"main": "src/main.ts",
26+
"polyfills": "src/polyfills.ts",
27+
"tsConfig": "tsconfig.app.json",
28+
"inlineStyleLanguage": "scss",
29+
"assets": [
30+
"src/favicon.ico",
31+
"src/assets"
32+
],
33+
"styles": [
34+
"src/styles.scss"
35+
],
36+
"scripts": []
37+
},
38+
"configurations": {
39+
"production": {
40+
"budgets": [
41+
{
42+
"type": "initial",
43+
"maximumWarning": "500kb",
44+
"maximumError": "1mb"
45+
},
46+
{
47+
"type": "anyComponentStyle",
48+
"maximumWarning": "2kb",
49+
"maximumError": "4kb"
50+
}
51+
],
52+
"fileReplacements": [
53+
{
54+
"replace": "src/environments/environment.ts",
55+
"with": "src/environments/environment.prod.ts"
56+
}
57+
],
58+
"outputHashing": "all"
59+
},
60+
"development": {
61+
"buildOptimizer": false,
62+
"optimization": false,
63+
"vendorChunk": true,
64+
"extractLicenses": false,
65+
"sourceMap": true,
66+
"namedChunks": true
67+
}
68+
},
69+
"defaultConfiguration": "production"
70+
},
71+
"serve": {
72+
"builder": "@angular-devkit/build-angular:dev-server",
73+
"configurations": {
74+
"production": {
75+
"browserTarget": "harness-e2e-cli:build:production"
76+
},
77+
"development": {
78+
"browserTarget": "harness-e2e-cli:build:development"
79+
}
80+
},
81+
"defaultConfiguration": "development"
82+
},
83+
"extract-i18n": {
84+
"builder": "@angular-devkit/build-angular:extract-i18n",
85+
"options": {
86+
"browserTarget": "harness-e2e-cli:build"
87+
}
88+
},
89+
"test": {
90+
"builder": "@angular-devkit/build-angular:karma",
91+
"options": {
92+
"main": "src/test.ts",
93+
"polyfills": "src/polyfills.ts",
94+
"tsConfig": "tsconfig.spec.json",
95+
"karmaConfig": "karma.conf.js",
96+
"inlineStyleLanguage": "scss",
97+
"assets": [
98+
"src/favicon.ico",
99+
"src/assets"
100+
],
101+
"styles": [
102+
"src/styles.scss"
103+
],
104+
"scripts": []
105+
}
106+
}
107+
}
108+
}
109+
},
110+
"defaultProject": "harness-e2e-cli"
111+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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'),
13+
require('@angular-devkit/build-angular/plugins/karma'),
14+
],
15+
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
22+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
23+
},
24+
jasmineHtmlReporter: {
25+
suppressAll: true, // removes the duplicated traces
26+
},
27+
coverageReporter: {
28+
dir: require('path').join(__dirname, './coverage/harness-e2e-cli'),
29+
subdir: '.',
30+
reporters: [{type: 'html'}, {type: 'text-summary'}],
31+
},
32+
reporters: ['progress', 'kjhtml'],
33+
port: 9876,
34+
colors: true,
35+
logLevel: config.LOG_INFO,
36+
autoWatch: true,
37+
browsers: ['Chrome'],
38+
singleRun: false,
39+
restartOnFileChange: true,
40+
});
41+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "harness-e2e-cli",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "file:../../node_modules/@angular/animations",
14+
"@angular/cdk": "file:../../dist/releases/cdk",
15+
"@angular/common": "file:../../node_modules/@angular/common",
16+
"@angular/compiler": "file:../../node_modules/@angular/compiler",
17+
"@angular/core": "file:../../node_modules/@angular/core",
18+
"@angular/forms": "file:../../node_modules/@angular/forms",
19+
"@angular/material": "file:../../dist/releases/material",
20+
"@angular/platform-browser": "file:../../node_modules/@angular/platform-browser",
21+
"@angular/platform-browser-dynamic": "file:../../node_modules/@angular/platform-browser-dynamic",
22+
"@angular/router": "file:../../node_modules/@angular/router",
23+
"rxjs": "file:../../node_modules/rxjs",
24+
"tslib": "^2.3.0",
25+
"zone.js": "~0.11.4"
26+
},
27+
"devDependencies": {
28+
"@angular-devkit/build-angular": "file:../../node_modules/@angular-devkit/build-angular",
29+
"@angular/cli": "file:../../node_modules/@angular/cli",
30+
"@angular/compiler-cli": "file:../../node_modules/@angular/compiler-cli",
31+
"@types/jasmine": "~3.10.0",
32+
"@types/node": "^12.11.1",
33+
"@types/selenium-webdriver": "3.0.19",
34+
"concurrently": "^7.0.0",
35+
"jasmine": "^4.0.2",
36+
"jasmine-core": "~3.10.0",
37+
"karma": "~6.3.0",
38+
"karma-chrome-launcher": "~3.1.0",
39+
"karma-coverage": "~2.1.0",
40+
"karma-jasmine": "~4.0.0",
41+
"karma-jasmine-html-reporter": "~1.7.0",
42+
"selenium-webdriver": "3.6.0",
43+
"ts-node": "~9.1.1",
44+
"typescript": "file:../../node_modules/typescript",
45+
"wait-on": "^6.0.0"
46+
}
47+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<mat-form-field>
2+
<mat-label>Select</mat-label>
3+
<mat-select>
4+
<mat-option value="first">First</mat-option>
5+
<mat-option value="second">Second</mat-option>
6+
</mat-select>
7+
</mat-form-field>

integration/harness-e2e-cli/src/app/app.component.scss

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {Component} from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-root',
5+
templateUrl: './app.component.html',
6+
styleUrls: ['./app.component.scss'],
7+
})
8+
export class AppComponent {
9+
title = 'harness-e2e-cli';
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {NgModule} from '@angular/core';
2+
import {BrowserModule} from '@angular/platform-browser';
3+
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
4+
5+
import {AppComponent} from './app.component';
6+
import {MatSelectModule} from '@angular/material/select';
7+
import {MatFormFieldModule} from '@angular/material/form-field';
8+
9+
@NgModule({
10+
declarations: [AppComponent],
11+
imports: [MatSelectModule, MatFormFieldModule, NoopAnimationsModule, BrowserModule],
12+
providers: [],
13+
bootstrap: [AppComponent],
14+
})
15+
export class AppModule {}

integration/harness-e2e-cli/src/assets/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true,
3+
};

0 commit comments

Comments
 (0)