Skip to content

Commit

Permalink
fix(testing): fix project config might not be defined (#22174)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Mar 6, 2024
1 parent 1731ad8 commit 3260f41
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ function ensureDependencies(tree: Tree, options: NormalizedSchema) {
}

function normalizeOptions(tree: Tree, options: CypressE2EConfigSchema) {
const projectConfig = readProjectConfiguration(tree, options.project);
const projectConfig: ProjectConfiguration | undefined =
readProjectConfiguration(tree, options.project);
if (projectConfig?.targets?.e2e) {
throw new Error(`Project ${options.project} already has an e2e target.
Rename or remove the existing e2e target.`);
Expand All @@ -134,7 +135,7 @@ Rename or remove the existing e2e target.`);
if (
!options.baseUrl &&
!options.devServerTarget &&
!projectConfig.targets.serve
!projectConfig?.targets?.serve
) {
throw new Error(`The project ${options.project} does not have a 'serve' target.
In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:<configName>]', or a baseUrl option`);
Expand All @@ -144,7 +145,7 @@ In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:

const devServerTarget =
options.devServerTarget ??
(projectConfig.targets.serve ? `${options.project}:serve` : undefined);
(projectConfig?.targets?.serve ? `${options.project}:serve` : undefined);

if (!options.baseUrl && !devServerTarget) {
throw new Error('Either baseUrl or devServerTarget must be provided');
Expand Down

0 comments on commit 3260f41

Please sign in to comment.