-
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
"must only be invoked from the spec file or support file." errors using cy.selectFile() & cy.readFile() #27457
Comments
Hi @S-Lomax, In 12.15 we did do some work around privileged commands. However your example does not give enough context into how you are calling these functions that would cause this problem. In order to give our engineers the best chance at recreating your problem, please create a reproducible example using a fork of Cypress Test Tiny. This gives us the best chance of seeing exactly what you are seeing and being able to investigate effectively. |
Hi @nagash77, thank you for your response. So far we've been unable to reproduce the issue using https://github.com/cypress-io/cypress-test-tiny, even when we change the URL to our own app and use the same code. We've tried clearing the cypress cache and reinstalling cypress but still hit the same issue every time. Is there any other information we might be able to give you that would help? |
Not sure it is linked to a cache problem, as we are facing the same issue on our CI since upgrading from 12.14.0 to 12.17.3 and we don't have any cache on it. Haven't figured out a way to reproduce it yet either. |
HI @nagash77 I have the same problem as mentioned above. We updated our cypress from 10 to the newest version and for some reason, this line just stopped working:
I'm getting the same error: must only be invoked from the spec file or support file |
Hi everyone, i'm still experiencing the same issue too. It was working on cypress 12.14.0 but since not. Cypress Version12.17.3 Test code to reproduce:
Current behavior |
Hi @jbarthe at a glance that test should work. Are you able to create a reproducible example using a fork of Cypress Test Tiny. This gives us the best chance of seeing exactly what you are seeing and being able to investigate effectively. |
@BloodyRain2k We'd really like to address this issue if it's happening unwarranted to users and randomly. Can anyone provide a reproducible example? Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide. |
Hi @jennifer-shehane we've been able to reproduce the issue using a fork of but only using our application. We're currently trying to work on a solution where we can provide a successful reproduction to you without giving access to our application. |
I have had this problem since attempting to update from 12.8.1 to 13.2.0. This tiny change fixed it in my particular case: This line works in 12.8.1 and fails in 13.2.0 with the error: "must only be invoked from the spec file or support file."
Changing the line to this works in 13.2.0:
|
@newell-paul I have the same problem: after upgrading Cypress to 13.3.1. getting this error: must only be invoked from the spec file or support file. I was using cypress v11.2.0 and cy.readFile command like this: cy.wrap(<some_path>).then(cy.reafFile) In v13.3.1 I have to change it to this: cy.wrap(<some_path>).then(path => cy.readFile(path)) |
Same problem on version 13.3.2 mb try to clean cache on your npm ? |
@jennifer-shehane, still working on getting a reproduction using Cypress Test Tiny but one thing we have noticed is that our site uses basic auth and when we bypass basic auth we no longer receive the error. |
Hi @jennifer-shehane / @nagash77 we've managed to reproduce using a fork from the cypress tiny test which can be accessed here: Please let me know if you need any further information. |
@jennifer-shehane / @nagash77 bumping this thread again as we managed to reproduce using a fork from the cypress tiny test which can be accessed here: Looks like the cause of the issue in our case is when basic auth is on the site under test. Please let me know if you need any further information. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
Recently updated to Cypress 12.17.3 from 12.14 and are still getting "must only be invoked from the spec file or support file." errors when using commands
cy.selectFile()
,cy.readFile()
andcy.task()
.Exactly the same behaviour as https://github.com/cypress-io/cypress/issues/27149
Desired behavior
No response
Test code to reproduce
Cypress Version
12.17.3
Node version
18.16.1
Operating System
Windows 10.0.19045.3208
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: