Skip to content

Commit

Permalink
build: generate a new app in ng new test (angular#27062)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored May 9, 2023
1 parent 3b75b01 commit 9b0d9fd
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 693 deletions.
16 changes: 0 additions & 16 deletions integration/ng-add-standalone/.editorconfig

This file was deleted.

42 changes: 0 additions & 42 deletions integration/ng-add-standalone/.gitignore

This file was deleted.

19 changes: 19 additions & 0 deletions integration/ng-add-standalone/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ npmPackageMappings = dicts.add(
},
)

# Name of the generated app.
APP_NAME = "ng-add-standalone"

node_integration_test(
name = "test",
srcs = glob(["**/*"]),
Expand All @@ -19,6 +22,22 @@ node_integration_test(
# See: https://github.com/yarnpkg/yarn/issues/2165.
# TODO(devversion): determine if a solution/workaround could live in the test runner.
"yarn install --cache-folder .yarn_cache_folder/",

# Generate a new standalone project with the default options.
# Skip installation since we installed the dependencies already.
"yarn ng new --defaults --standalone --skip-install --style=scss --name=%s" % APP_NAME,
# Delete the package.json that the CLI generated since we want to use the existing one.
"rm -f %s/package.json" % APP_NAME,
# Delete the Karma config since we need to use a headless browser.
"rm -f %s/karma.conf.js" % APP_NAME,
# We can't name the checked-in config `angular.json`, because the CLI doesn't allow
# `ng new` to run in a directory that has an `angular.json` already.
"mv _angular.json angular.json",
# Delete the angular.json since we have a specific config for the test.
"rm -f %s/angular.json" % APP_NAME,
# Move the generated project one level up so it can reuse the package.json and node_modules.
"mv %s/* ." % APP_NAME,
# Install Material and run the unit tests.
"yarn ng add @angular/material",
"yarn test",
],
Expand Down
27 changes: 0 additions & 27 deletions integration/ng-add-standalone/README.md

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 9b0d9fd

Please sign in to comment.