Skip to content

Commit 1546b3f

Browse files
authored
build: create ng add integration test using ng new (#27096)
Reworks the `ng add` integration test to run `ng new` first which should make it easier to keep up with changes to the project layout.
1 parent aecb18a commit 1546b3f

26 files changed

+24
-848
lines changed

integration/ng-add-standalone/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = function (config) {
4343
// Chrome cannot run with sandbox enabled as this test already runs within
4444
// the Bazel sandbox environment and the sandboxes would conflict otherwise.
4545
browsers: ['ChromeHeadlessNoSandbox'],
46-
singleRun: false,
46+
singleRun: true,
4747
restartOnFileChange: true,
4848
});
4949
};

integration/ng-add/.browserslistrc

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

integration/ng-add/.editorconfig

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

integration/ng-add/.gitignore

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

integration/ng-add/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"
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 project with the default options.
27+
# Skip installation since we installed the dependencies already.
28+
"yarn ng new --defaults --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/README.md

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

integration/ng-add/angular.json renamed to integration/ng-add/_angular.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"outputPath": "dist/ng-add",
2424
"index": "src/index.html",
2525
"main": "src/main.ts",
26-
"polyfills": "src/polyfills.ts",
26+
"polyfills": ["zone.js"],
2727
"tsConfig": "tsconfig.app.json",
2828
"inlineStyleLanguage": "scss",
2929
"assets": ["src/favicon.ico", "src/assets"],
@@ -44,12 +44,6 @@
4444
"maximumError": "4kb"
4545
}
4646
],
47-
"fileReplacements": [
48-
{
49-
"replace": "src/environments/environment.ts",
50-
"with": "src/environments/environment.prod.ts"
51-
}
52-
],
5347
"outputHashing": "all"
5448
},
5549
"development": {
@@ -84,15 +78,13 @@
8478
"test": {
8579
"builder": "@angular-devkit/build-angular:karma",
8680
"options": {
87-
"main": "src/test.ts",
88-
"polyfills": "src/polyfills.ts",
81+
"polyfills": ["zone.js", "zone.js/testing"],
8982
"tsConfig": "tsconfig.spec.json",
9083
"karmaConfig": "karma.conf.js",
9184
"inlineStyleLanguage": "scss",
9285
"assets": ["src/favicon.ico", "src/assets"],
9386
"styles": ["src/styles.scss"],
94-
"scripts": [],
95-
"watch": false
87+
"scripts": []
9688
}
9789
}
9890
}

integration/ng-add/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = function (config) {
4343
// Chrome cannot run with sandbox enabled as this test already runs within
4444
// the Bazel sandbox environment and the sandboxes would conflict otherwise.
4545
browsers: ['ChromeHeadlessNoSandbox'],
46-
singleRun: false,
46+
singleRun: true,
4747
restartOnFileChange: true,
4848
});
4949
};

integration/ng-add/src/app/app-routing.module.ts

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

0 commit comments

Comments
 (0)