Skip to content

Resurfacing of command 'must only be invoked from the spec file or support file.' #27149

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

Closed
RobHannay opened this issue Jun 27, 2023 · 4 comments · Fixed by #27157
Closed

Resurfacing of command 'must only be invoked from the spec file or support file.' #27149

RobHannay opened this issue Jun 27, 2023 · 4 comments · Fixed by #27157
Assignees
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug

Comments

@RobHannay
Copy link

RobHannay commented Jun 27, 2023

Current behavior

  • Running selectFile with action: 'drag-drop' throws Error: CypressError: cy.selectFile() must only be invoked from the spec file or support file.

Desired behavior

Fixture would be 'dropped' on the file input without erroring

Test code to reproduce

https://github.com/RobHannay/cypress-test-tiny

  cy.get('input[type=file]')
    .first()
    .selectFile('cypress/fixtures/videos/Koala1.mp4', { force: true }, { action: 'drag-drop' });

Cypress Version

12.16.0

Node version

18.16

Operating System

macOS 13.4.1

Debug Logs

(Has some possibly sensitive info on our corporate codebase; can make available privately)

Other

Continuation of #27099.

@chrisbreiding chrisbreiding self-assigned this Jun 27, 2023
@chrisbreiding
Copy link
Contributor

Sorry to see you're encountering this issue. Thanks for reporting it with a reproduction.

cy.selectFile() only takes one options argument, so this can be fixed by calling it like so:

cy.get('input[type=file]')
    .first()
    .selectFile('cypress/fixtures/videos/Koala1.mp4', { force: true, action: 'drag-drop' });

Regardless, calling it with an extra argument should not trigger that error, so this is a bug that we'll look into fixing.

@chrisbreiding chrisbreiding added type: bug E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. labels Jun 27, 2023
@elGatoMantocko
Copy link

Still able to reproduce #27099 via cypress-localstorage-commands.

#27099 (comment)

@RobHannay
Copy link
Author

Sorry to see you're encountering this issue. Thanks for reporting it with a reproduction.

cy.selectFile() only takes one options argument, so this can be fixed by calling it like so:

cy.get('input[type=file]')
    .first()
    .selectFile('cypress/fixtures/videos/Koala1.mp4', { force: true, action: 'drag-drop' });

Regardless, calling it with an extra argument should not trigger that error, so this is a bug that we'll look into fixing.

Ah, of course!! 🤦 Thanks @chrisbreiding. Will leave this open as I guess a change in 12.15/12.16 has started causing this to error

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 6, 2023

Released in 12.17.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.17.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants