Skip to content

Commit

Permalink
fix(testing): warn and default if sourceRoot isn't set for ng CT (#13940
Browse files Browse the repository at this point in the history
)
  • Loading branch information
barbados-clemens authored Dec 21, 2022
1 parent 3a2721b commit 88f860d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/angular/plugins/component-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,20 @@ function normalizeBuildTargetOptions(
buildOptions.scripts = [];
buildOptions.stylePreprocessorOptions = { includePaths: [] };
}
const { root, sourceRoot } =

const config =
buildContext.projectGraph.nodes[buildContext.projectName]?.data;

if (!config.sourceRoot) {
logger.warn(stripIndents`Unable to find the 'sourceRoot' in the project configuration.
Will set 'sourceRoot' to '${config.root}/src'
Note: this may fail, setting the correct 'sourceRoot' for ${buildContext.projectName} in the project.json file will ensure the correct value is used.`);
config.sourceRoot = joinPathFragments(config.root, 'src');
}

return {
root: joinPathFragments(offset, root),
sourceRoot: joinPathFragments(offset, sourceRoot),
root: joinPathFragments(offset, config.root),
sourceRoot: joinPathFragments(offset, config.sourceRoot),
buildOptions,
};
}
Expand Down

0 comments on commit 88f860d

Please sign in to comment.