-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: Fix issue with undefined or extra args passed to privileged commands #27157
Conversation
}) | ||
|
||
it('handles extra, unexpected arguments', () => { | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// @ts-ignore | |
// @ts-expect-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I always forget to use that instead of ts-ignore. Addressed in 45a6abc
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
Fixes the following two issues that erroneously cause the
<command> must only be invoked from the spec file or support file
error:Command is called with an extra argument that isn't part of its API.
Privileged command arguments are collected on invocation generically, with no knowledge of how many arguments are valid. However, each command implementation would only send known arguments when it's run, making the argument comparison falsely fail. The solution is for the implementations to send all arguments, even if they're not used by the command.
Command is called with a trailing
undefined
argument. This usually happens when one of the arguments is a variable.This was a bug in how trailing undefined arguments were being trimmed. Before, they were trimmed after being serialized, which never worked since any
undefined
values became strings. There was an issue with the test for that case. The implementation has been fixed and the test has been improved.PR Tasks
cypress-documentation
?type definitions
?