Skip to content

Commit 6fd1393

Browse files
committed
build: unable to run schematics tests through test script
Fixes not being able to run the schematics tests through `yarn test`. The logic for resolving the package was correct, but we were appending the wrong target name. Fixes #19182.
1 parent 658896f commit 6fd1393

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

scripts/run-component-tests.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,14 @@ if (local && (components.length > 1 || all)) {
6262
}
6363

6464
const bazelBinary = `yarn -s ${watch ? 'ibazel' : 'bazel'}`;
65-
const testTargetName =
66-
`unit_tests_${local ? 'local' : firefox ? 'firefox-local' : 'chromium-local'}`;
6765
const configFlag = viewEngine ? '--config=view-engine' : '';
6866

6967
// If `all` has been specified as component, we run tests for all components
7068
// in the repository. The `--firefox` flag can be still specified.
7169
if (all) {
7270
shelljs.exec(
73-
`${bazelBinary} test //src/... --test_tag_filters=-e2e,-browser:${testTargetName} ` +
74-
`--build_tag_filters=-browser:${testTargetName} --build_tests_only ${configFlag}`);
71+
`${bazelBinary} test //src/... --test_tag_filters=-e2e,-browser:${getTargetName()} ` +
72+
`--build_tag_filters=-browser:${getTargetName()} --build_tests_only ${configFlag}`);
7573
return;
7674
}
7775

@@ -90,7 +88,7 @@ if (!components.length) {
9088
const bazelAction = local ? 'run' : 'test';
9189
const testLabels = components
9290
.map(t => correctTypos(t))
93-
.map(t => `${getBazelPackageOfComponentName(t)}:${testTargetName}`);
91+
.map(t => `${getBazelPackageOfComponentName(t)}:${getTargetName(t)}`);
9492

9593
// Runs Bazel for the determined test labels.
9694
shelljs.exec(`${bazelBinary} ${bazelAction} ${testLabels.join(' ')} ${configFlag}`);
@@ -143,3 +141,13 @@ function correctTypos(target) {
143141
function convertPathToPosix(pathName) {
144142
return pathName.replace(/\\/g, '/');
145143
}
144+
145+
/** Gets the name of the target that should be run. */
146+
function getTargetName(packageName) {
147+
// Schematics don't have _local and browser targets.
148+
if (packageName && packageName.endsWith('schematics')) {
149+
return 'unit_tests';
150+
}
151+
152+
return `unit_tests_${local ? 'local' : (firefox ? 'firefox-local' : 'chromium-local')}`;
153+
}

0 commit comments

Comments
 (0)