Skip to content

Commit f09e669

Browse files
committed
build: generate a new app in ng new test (#27062)
Currently the `ng new` integration test uses a pre-generated app which we need to keep up to date. This can cause us to miss changes in the project structure between CLI versions. These changes switch to generating the project on-the-fly and adding Material to it instead. I've only done this for the standalone test to verify the approach, but it should be applied to the `ng add` test as well. (cherry picked from commit 9b0d9fd)
1 parent 449bc4e commit f09e669

19 files changed

+19
-693
lines changed

integration/ng-add-standalone/.editorconfig

Lines changed: 0 additions & 16 deletions
This file was deleted.

integration/ng-add-standalone/.gitignore

Lines changed: 0 additions & 42 deletions
This file was deleted.

integration/ng-add-standalone/BUILD.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ npmPackageMappings = dicts.add(
1010
},
1111
)
1212

13+
# Name of the generated app.
14+
APP_NAME = "ng-add-standalone"
15+
1316
node_integration_test(
1417
name = "test",
1518
srcs = glob(["**/*"]),
@@ -19,6 +22,22 @@ node_integration_test(
1922
# See: https://github.com/yarnpkg/yarn/issues/2165.
2023
# TODO(devversion): determine if a solution/workaround could live in the test runner.
2124
"yarn install --cache-folder .yarn_cache_folder/",
25+
26+
# Generate a new standalone project with the default options.
27+
# Skip installation since we installed the dependencies already.
28+
"yarn ng new --defaults --standalone --skip-install --style=scss --name=%s" % APP_NAME,
29+
# Delete the package.json that the CLI generated since we want to use the existing one.
30+
"rm -f %s/package.json" % APP_NAME,
31+
# Delete the Karma config since we need to use a headless browser.
32+
"rm -f %s/karma.conf.js" % APP_NAME,
33+
# We can't name the checked-in config `angular.json`, because the CLI doesn't allow
34+
# `ng new` to run in a directory that has an `angular.json` already.
35+
"mv _angular.json angular.json",
36+
# Delete the angular.json since we have a specific config for the test.
37+
"rm -f %s/angular.json" % APP_NAME,
38+
# Move the generated project one level up so it can reuse the package.json and node_modules.
39+
"mv %s/* ." % APP_NAME,
40+
# Install Material and run the unit tests.
2241
"yarn ng add @angular/material",
2342
"yarn test",
2443
],

integration/ng-add-standalone/README.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)