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: Exit when both --e2e and --component flags are passed in #18855

Merged
merged 4 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ const parseOpts = (opts) => {

debug('parsed cli options %o', cleanOpts)

if (cleanOpts.component && cleanOpts.e2e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

I had not realized exactly how many different ways we have to throw errors in the command line. It might be a worthwhile project to examine and consider unifying at some point.

util.logErrorExit1(new Error(stripIndent`
Error: You passed both --component and --e2e, but only one can be provided.

See https://docs.cypress.io/ for more information on testing types.
BlueWinds marked this conversation as resolved.
Show resolved Hide resolved
`))
}

return cleanOpts
}

Expand Down
9 changes: 9 additions & 0 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,5 +580,14 @@ describe('util', () => {
ciBuildId: 'my ci build id',
})
})

it('throws when both --component and --e2e are given', () => {
expect(() => {
return util.parseOpts({
component: true,
e2e: true,
})
}).to.throw(Error)
})
})
})