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): fix project config might not be defined #22174

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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