Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): handle path offsets for angular component testing #12863

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions e2e/angular-extensions/src/cypress-component-tests.test.ts
Expand Up @@ -70,7 +70,15 @@ export class BtnStandaloneComponent {
`
);
const btnModuleName = names(usedInAppLibName).className;
updateFile(
`apps/${appName}/src/app/app.component.scss`,
`
@use 'styleguide' as *;

h1 {
@include headline;
}`
);
updateFile(
`apps/${appName}/src/app/app.module.ts`,
`
Expand Down Expand Up @@ -135,7 +143,21 @@ import {CommonModule} from '@angular/common';

// make sure assets from the workspace root work.
createFile('libs/assets/data.json', JSON.stringify({ data: 'data' }));
createFile(
'assets/styles/styleguide.scss',
`
@mixin headline {
font-weight: bold;
color: darkkhaki;
background: lightcoral;
font-weight: 24px;
}
`
);
updateProjectConfig(appName, (config) => {
config.targets['build'].options.stylePreprocessorOptions = {
includePaths: ['assets/styles'],
};
config.targets['build'].options.assets.push({
glob: '**/*',
input: 'libs/assets',
Expand Down
10 changes: 10 additions & 0 deletions packages/angular/plugins/component-testing.ts
Expand Up @@ -211,11 +211,21 @@ function normalizeBuildTargetOptions(
? joinPathFragments(offset, script)
: { ...script, input: joinPathFragments(offset, script.input) };
});
if (buildOptions.stylePreprocessorOptions?.includePaths.length > 0) {
buildOptions.stylePreprocessorOptions = {
includePaths: buildOptions.stylePreprocessorOptions.includePaths.map(
(path) => {
return joinPathFragments(offset, path);
}
),
};
}
} else {
const stylePath = getTempStylesForTailwind(ctContext);
buildOptions.styles = stylePath ? [stylePath] : [];
buildOptions.assets = [];
buildOptions.scripts = [];
buildOptions.stylePreprocessorOptions = { includePaths: [] };
}
const { root, sourceRoot } =
buildContext.projectGraph.nodes[buildContext.projectName].data;
Expand Down