Skip to content

Commit 86f42b0

Browse files
committed
fixup! build: add option for running all component tests
Rename yarn test --all to yarn test all
1 parent eccbfa8 commit 86f42b0

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

scripts/run-component-tests.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Script that simplifies the workflow of running unit tests for a component
55
* using Bazel. Here are a few examples:
66
*
7+
* node ./scripts/run-component-tests all | Runs tests for all components
78
* node ./scripts/run-component-tests button | Runs Material button tests
89
* node ./scripts/run-component-tests overlay | Runs CDK overlay tests
910
* node ./scripts/run-component-tests src/cdk/a11y | Runs CDK a11y tests
@@ -14,7 +15,6 @@
1415
* --local | If specified, no browser will be launched.
1516
* --firefox | Instead of Chrome being used for tests, Firefox will be used.
1617
* --no-watch | Watch mode is enabled by default. This flag opts-out to standard Bazel.
17-
* --all | Runs tests for all components in the project.
1818
*/
1919

2020
const minimist = require('minimist');
@@ -39,11 +39,14 @@ shelljs.set('-e');
3939
shelljs.cd(projectDir);
4040

4141
// Extracts the supported command line options.
42-
const {_: components, local, firefox, watch, all} = minimist(args, {
43-
boolean: ['local', 'firefox', 'watch', 'all'],
42+
const {_: components, local, firefox, watch} = minimist(args, {
43+
boolean: ['local', 'firefox', 'watch'],
4444
default: {watch: true},
4545
});
4646

47+
// Whether tests for all components should be run.
48+
const all = components.length === 1 && components[0] === 'all';
49+
4750
// We can only run a single target with "--local". Running multiple targets within the
4851
// same Karma server is not possible since each test target runs isolated from the others.
4952
if (local && (components.length > 1 || all)) {
@@ -57,14 +60,9 @@ const bazelBinary = `yarn -s ${watch ? 'ibazel' : 'bazel'}`;
5760
const testTargetName =
5861
`unit_tests_${local ? 'local' : firefox ? 'firefox-local' : 'chromium-local'}`;
5962

60-
// If the `--all` flag has been specified, we run tests for all components in the
61-
// repository. The `--firefox` flag can be still specified.
63+
// If `all` has been specified as component, we run tests for all components
64+
// in the repository. The `--firefox` flag can be still specified.
6265
if (all) {
63-
if (components.length) {
64-
console.error(
65-
chalk.red('Script cannot be run with `--all` if individual components are specified.'));
66-
process.exit(1);
67-
}
6866
shelljs.exec(
6967
`${bazelBinary} test //src/... --test_tag_filters=-e2e,-browser:${testTargetName} ` +
7068
`--build_tag_filters=-browser:${testTargetName} --build_tests_only`);
@@ -74,10 +72,10 @@ if (all) {
7472
// Exit if no component has been specified.
7573
if (!components.length) {
7674
console.error(chalk.red(
77-
'No component specified. Please either specify individual components, or pass the "--all" ' +
78-
'flag in order to run tests for all components.'));
75+
'No component specified. Please either specify individual components, or pass "all" ' +
76+
'in order to run tests for all components.'));
7977
console.info(chalk.yellow('Below are a few examples of how the script can be run:'));
80-
console.info(chalk.yellow(` - yarn test --all`));
78+
console.info(chalk.yellow(` - yarn test all`));
8179
console.info(chalk.yellow(` - yarn test cdk/overlay material/stepper`));
8280
console.info(chalk.yellow(` - yarn test button toolbar`));
8381
process.exit(1);

0 commit comments

Comments
 (0)