Skip to content

Commit

Permalink
fix(testing): fix cypress project targets does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Feb 12, 2024
1 parent 7eb8394 commit 4b0be52
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/cypress/src/generators/configuration/configuration.ts
Expand Up @@ -7,6 +7,7 @@ import {
joinPathFragments,
offsetFromRoot,
parseTargetString,
ProjectConfiguration,
ProjectGraph,
readNxJson,
readProjectConfiguration,
Expand Down Expand Up @@ -220,21 +221,18 @@ async function addFiles(
projectGraph
);

const devServerProjectConfig = readProjectConfiguration(
tree,
parsedTarget.project
);
const devServerProjectConfig: ProjectConfiguration | undefined =
readProjectConfiguration(tree, parsedTarget.project);
// Add production e2e target if serve target is found
if (
parsedTarget.configuration !== 'production' &&
devServerProjectConfig.targets[parsedTarget.target]?.configurations?.[
'production'
]
devServerProjectConfig?.targets?.[parsedTarget.target]
?.configurations?.['production']
) {
webServerCommands.production = `nx run ${parsedTarget.project}:${parsedTarget.target}:production`;
}
// Add ci/static e2e target if serve target is found
if (devServerProjectConfig.targets?.['serve-static']) {
if (devServerProjectConfig?.targets?.['serve-static']) {
ciWebServerCommand = `nx run ${parsedTarget.project}:serve-static`;
}
}
Expand Down Expand Up @@ -278,6 +276,7 @@ async function addFiles(
function addTarget(tree: Tree, opts: NormalizedSchema) {
const projectConfig = readProjectConfiguration(tree, opts.project);
const cyVersion = installedCypressVersion();
projectConfig.targets ??= {};
projectConfig.targets.e2e = {
executor: '@nx/cypress:cypress',
options: {
Expand Down

0 comments on commit 4b0be52

Please sign in to comment.