From 5f3f634fb3329b7b03660e449412d5f3cadaed71 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Sat, 2 May 2020 11:04:11 +0200 Subject: [PATCH] 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. --- scripts/run-component-tests.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/run-component-tests.js b/scripts/run-component-tests.js index 05dde1a213c6..3312ccb4ccdb 100644 --- a/scripts/run-component-tests.js +++ b/scripts/run-component-tests.js @@ -86,11 +86,10 @@ if (!components.length) { process.exit(1); } -const testTargetName = `unit_tests_${local ? 'local' : browserName}`; const bazelAction = local ? 'run' : 'test'; const testLabels = components .map(t => correctTypos(t)) - .map(t => `${getBazelPackageOfComponentName(t)}:${testTargetName}`); + .map(t => `${getBazelPackageOfComponentName(t)}:${getTargetName(t)}`); // Runs Bazel for the determined test labels. shelljs.exec(`${bazelBinary} ${bazelAction} ${testLabels.join(' ')} ${configFlag}`); @@ -143,3 +142,13 @@ function correctTypos(target) { function convertPathToPosix(pathName) { return pathName.replace(/\\/g, '/'); } + +/** Gets the name of the target that should be run. */ +function getTargetName(packageName) { + // Schematics don't have _local and browser targets. + if (packageName && packageName.endsWith('schematics')) { + return 'unit_tests'; + } + + return `unit_tests_${local ? 'local' : browserName}`; +}