Skip to content

Commit 1576189

Browse files
committed
test: setup integration test for running ng add
Sets up the integration test for running `ng add` to run with Bazel. The test is also run with NodeJS v12 which does not support ES2020 output.
1 parent afbe73f commit 1576189

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

.bazelignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ node_modules
22

33
integration/ng-update-v13/.angular
44
integration/ng-update-v13/node_modules
5+
6+
integration/ng-add/.angular
7+
integration/ng-add/node_modules

integration/ng-add/BUILD.bazel

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 ng add @angular/material",
23+
"yarn test",
24+
],
25+
npm_packages = npmPackageMappings,
26+
tags = [
27+
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
28+
# Additionally, we need to disable RBE as this test relies on internet
29+
# access for installing the NPM packages.
30+
"no-sandbox",
31+
"no-remote-exec",
32+
],
33+
)
34+
35+
node_integration_test(
36+
name = "test_node12",
37+
srcs = glob(["**/*"]),
38+
commands = [
39+
# Note: We use a cache folder within the integration test as otherwise
40+
# the NPM package mapped archive would be cached in the system.
41+
# See: https://github.com/yarnpkg/yarn/issues/2165.
42+
# TODO(devversion): determine if a solution/workaround could live in the test runner.
43+
"yarn install --cache-folder .yarn_cache_folder/",
44+
"node --version",
45+
"yarn node --version",
46+
"yarn ng add @angular/material",
47+
"yarn test",
48+
],
49+
npm_packages = npmPackageMappings,
50+
tags = [
51+
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
52+
# Additionally, we need to disable RBE as this test relies on internet
53+
# access for installing the NPM packages.
54+
"no-sandbox",
55+
"no-remote-exec",
56+
],
57+
tool_mappings = {
58+
"@node12_host//:yarn_bin": "yarn",
59+
"@node12_host//:node_bin": "node",
60+
},
61+
)

integration/ng-add/karma.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

4+
// This code runs within Bazel where the environment does not have access to
5+
// the system Chrome browser. To workaround this we use Puppeteer to provide
6+
// a local version of Chromium that can run within Bazel.
7+
process.env.CHROME_BIN = require('puppeteer').executablePath();
8+
49
module.exports = function (config) {
510
config.set({
611
basePath: '',

0 commit comments

Comments
 (0)