Skip to content

Commit 267a0c5

Browse files
committed
test(@angular-devkit/build-webpack): add bazel integration test
1 parent 2be790f commit 267a0c5

22 files changed

+5118
-0
lines changed

integration/BUILD.bazel

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
load("//tools/npm_integration_test:npm_integration_test.bzl", "npm_integration_test")
2+
3+
filegroup(
4+
name = "build_webpack_test_sources",
5+
srcs = glob(
6+
include = ["build_webpack/**/*"],
7+
exclude = [
8+
"build_webpack/node_modules/**",
9+
"build_webpack/.yarn_local_cache/**",
10+
],
11+
),
12+
)
13+
14+
npm_integration_test(
15+
name = "build_webpack_test",
16+
check_npm_packages = [
17+
"@angular-devkit/architect",
18+
"@angular-devkit/build-webpack",
19+
"@angular-devkit/core",
20+
"@ngtools/webpack",
21+
],
22+
npm_packages = {
23+
"//packages/angular_devkit/architect:npm_package_archive": "@angular-devkit/architect",
24+
"//packages/angular_devkit/build_webpack:npm_package_archive": "@angular-devkit/build-webpack",
25+
"//packages/angular_devkit/core:npm_package_archive": "@angular-devkit/core",
26+
"//packages/ngtools/webpack:npm_package_archive": "@ngtools/webpack",
27+
},
28+
commands = [
29+
# Workaround https://github.com/yarnpkg/yarn/issues/2165
30+
# Yarn will cache file://dist URIs and not update
31+
"rm -rf ./.yarn_local_cache",
32+
"mkdir .yarn_local_cache",
33+
"patch-package-json",
34+
"$(rootpath @nodejs//:yarn_bin) install --cache-folder ./.yarn_local_cache",
35+
"$(rootpath @nodejs//:yarn_bin) test",
36+
"rm -rf ./.yarn_local_cache",
37+
],
38+
data = [
39+
"@nodejs//:yarn_bin",
40+
"@nodejs//:yarn_files",
41+
],
42+
test_files = ":build_webpack_test_sources"
43+
)

integration/build_webpack/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
8+
# dependencies
9+
/node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
testem.log
34+
/typings
35+
36+
# e2e
37+
/e2e/*.js
38+
/e2e/*.map
39+
40+
# System Files
41+
.DS_Store
42+
Thumbs.db
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "../../../../packages/angular_devkit/core/src/workspace/workspace-schema.json",
3+
"version": 1,
4+
"newProjectRoot": "./projects",
5+
"cli": {},
6+
"schematics": {},
7+
"targets": {},
8+
"projects": {
9+
"app": {
10+
"root": "src",
11+
"sourceRoot": "src",
12+
"projectType": "application",
13+
"schematics": {},
14+
"targets": {
15+
"build-webpack": {
16+
"builder": "@angular-devkit/build-webpack:webpack",
17+
"options": {
18+
"webpackConfig": "webpack.config.js"
19+
}
20+
},
21+
"serve-webpack": {
22+
"builder": "@angular-devkit/build-webpack:webpack-dev-server",
23+
"options": {
24+
"webpackConfig": "webpack.config.js"
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "build_webpack_intergration",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"test": "ts-node node_modules/jasmine/bin/jasmine test.ts"
8+
},
9+
"dependencies": {
10+
"@angular-devkit/architect": "^0.900.5",
11+
"@angular-devkit/build-webpack": "^0.900.5",
12+
"@angular-devkit/core": "^9.0.5",
13+
"@angular/common": "9.0.2",
14+
"@angular/compiler": "9.0.2",
15+
"@angular/compiler-cli": "9.0.2",
16+
"@angular/core": "9.0.2",
17+
"@angular/platform-browser": "9.0.2",
18+
"@angular/platform-browser-dynamic": "9.0.2",
19+
"@ngtools/webpack": "^9.0.5",
20+
"@types/jasmine": "^3.5.8",
21+
"jasmine": "^3.5.0",
22+
"raw-loader": "4.0.0",
23+
"rxjs": "^6.5.4",
24+
"ts-node": "^8.6.2",
25+
"tslib": "^1.11.1",
26+
"typescript": "3.7",
27+
"webpack": "4.42.0",
28+
"webpack-dev-server": "3.10.3",
29+
"zone.js": "^0.10.2"
30+
},
31+
"resolutions": {
32+
"**/@angular-devkit/architect": "^0.900.5",
33+
"**/@angular-devkit/build-webpack": "^0.900.5",
34+
"**/@angular-devkit/core": "^9.0.5",
35+
"**/@ngtools/webpack": "^9.0.5"
36+
}
37+
}

integration/build_webpack/src/app/app.component.css

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--The content below is only a placeholder and can be replaced.-->
2+
<div style="text-align:center">
3+
<h1>
4+
Welcome to {{ title }}!
5+
</h1>
6+
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
7+
</div>
8+
<h2>Here are some links to help you start: </h2>
9+
<ul>
10+
<li>
11+
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12+
</li>
13+
<li>
14+
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15+
</li>
16+
<li>
17+
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
18+
</li>
19+
</ul>
20+
21+
<p i18n>i18n test</p>
22+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { TestBed, async } from '@angular/core/testing';
9+
import { AppComponent } from './app.component';
10+
describe('AppComponent', () => {
11+
beforeEach(async(() => {
12+
TestBed.configureTestingModule({
13+
declarations: [
14+
AppComponent
15+
],
16+
}).compileComponents();
17+
}));
18+
it('should create the app', async(() => {
19+
const fixture = TestBed.createComponent(AppComponent);
20+
const app = fixture.debugElement.componentInstance;
21+
expect(app).toBeTruthy();
22+
}));
23+
it(`should have as title 'app'`, async(() => {
24+
const fixture = TestBed.createComponent(AppComponent);
25+
const app = fixture.debugElement.componentInstance;
26+
expect(app.title).toEqual('app');
27+
}));
28+
it('should render title in a h1 tag', async(() => {
29+
const fixture = TestBed.createComponent(AppComponent);
30+
fixture.detectChanges();
31+
const compiled = fixture.debugElement.nativeElement;
32+
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
33+
}));
34+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { Component } from '@angular/core';
9+
10+
@Component({
11+
selector: 'app-root',
12+
templateUrl: './app.component.html',
13+
styleUrls: ['./app.component.css']
14+
})
15+
export class AppComponent {
16+
title = 'app';
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { BrowserModule } from '@angular/platform-browser';
9+
import { NgModule } from '@angular/core';
10+
11+
12+
import { AppComponent } from './app.component';
13+
14+
15+
@NgModule({
16+
declarations: [
17+
AppComponent
18+
],
19+
imports: [
20+
BrowserModule
21+
],
22+
providers: [],
23+
bootstrap: [AppComponent]
24+
})
25+
export class AppModule { }

integration/build_webpack/src/assets/.gitkeep

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
export const environment = {
9+
production: true
10+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
// The file contents for the current environment will overwrite these during build.
9+
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
10+
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
11+
// The list of which env maps to which file can be found in `.angular-cli.json`.
12+
13+
export const environment = {
14+
production: false
15+
};

integration/build_webpack/src/main.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { enableProdMode } from '@angular/core';
9+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
10+
11+
import { AppModule } from './app/app.module';
12+
import { environment } from './environments/environment';
13+
14+
if (environment.production) {
15+
enableProdMode();
16+
}
17+
18+
platformBrowserDynamic().bootstrapModule(AppModule)
19+
.catch(err => console.log(err));
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
/**
9+
* This file includes polyfills needed by Angular and is loaded before the app.
10+
* You can add your own extra polyfills to this file.
11+
*
12+
* This file is divided into 2 sections:
13+
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
14+
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
15+
* file.
16+
*
17+
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
18+
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
19+
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
20+
*
21+
* Learn more in https://angular.io/guide/browser-support
22+
*/
23+
24+
/***************************************************************************************************
25+
* BROWSER POLYFILLS
26+
*/
27+
28+
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
29+
// import 'core-js/es6/symbol';
30+
// import 'core-js/es6/object';
31+
// import 'core-js/es6/function';
32+
// import 'core-js/es6/parse-int';
33+
// import 'core-js/es6/parse-float';
34+
// import 'core-js/es6/number';
35+
// import 'core-js/es6/math';
36+
// import 'core-js/es6/string';
37+
// import 'core-js/es6/date';
38+
// import 'core-js/es6/array';
39+
// import 'core-js/es6/regexp';
40+
// import 'core-js/es6/map';
41+
// import 'core-js/es6/weak-map';
42+
// import 'core-js/es6/set';
43+
44+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
45+
// import 'classlist.js'; // Run `npm install --save classlist.js`.
46+
47+
/** IE10 and IE11 requires the following for the Reflect API. */
48+
// import 'core-js/es6/reflect';
49+
50+
/**
51+
* Required to support Web Animations `@angular/platform-browser/animations`.
52+
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
53+
**/
54+
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
55+
56+
57+
58+
/***************************************************************************************************
59+
* Zone JS is required by default for Angular itself.
60+
*/
61+
import 'zone.js/dist/zone'; // Included with Angular CLI.
62+
63+
64+
65+
/***************************************************************************************************
66+
* APPLICATION IMPORTS
67+
*/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/app",
5+
"module": "es2015",
6+
"types": []
7+
},
8+
"exclude": [
9+
"test.ts",
10+
"**/*.spec.ts"
11+
]
12+
}

0 commit comments

Comments
 (0)