-
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
Error using cy.task(): cy.task() must only be invoked from the spec file or support file #27784
Comments
Sorry to see you've encountered this issue and thank you for providing a simple reproduction. It appears to be a bug. We'll look into fixing it. In the meantime, you could work around it by calling cy.origin('https://google.com',()=>{
cy.task('showError')
}) I know it's less than ideal, especially since your actual test code is likely more complex, but it should get your tests passing while we work on getting out a fix. |
First of all thanks for taking charge of this problem I hope you can find a solution because I really need it to work even with an updated version of cypress. And yes, I confirm that the case in which I use it is much more complex than the example provided. Hoping to have good news soon, I wish you the best of luck in finding a solution. |
Hi, I get the same error when using I saw previous fixes around this (#27200), but apparently it's not enough. Will that be taken into account quickly (I really need to use latest version for Cypress Cloud and Test replay new awesome feature)? |
Same if using Too bad. Is there a kwown workaround @chrisbreiding? I just want to pass a string outside of the |
Any news about this? (I'm now using Cypress Cloud and I'm looking forward to have Test Replay with latest version 13) 🙏 |
@StephaneColson I plan to look into fixing this in the next week or two. I appreciate your patience and definitely want you to be able to take advantage of Test Replay! |
Awesome. Thx 👍 |
I hope is the next 👍 |
Was it closed because a solution was found? |
We've seen this in our e2e tests and it prevents us from upgrading to cypress 13. The problem seems to stem from (at least in our case) missing stack traces on the error objects generated in If this doesn't work i would welcome a config option to disable this security measure. |
Hi @chrisbreiding any news about this issue please ? Thanks |
Any updates on this? :) |
@StephaneColson, @dillon-miller2-carvana Unfortunately I haven't had the time to look into this yet, but it's still a priority to fix it in the near future. I'll be sure to post any updates when there's progress. |
Hi, I encounter the identical error when utilizing cy.task within a Cypress origin in version 13.2.0, no problems observed with the previously version |
We had this issue using Cypress 13.5.0. We were calling it from the |
Same problem here on 13.5.1 |
Sorry to push this again...but when do you plan to fix this? 🙏 If not planned soon, I should probably have to work on a workaround... 😞 |
I did have some time to look into this, but unfortunately there doesn't seem to be a straightforward solution, so I don't think we'll have a fix out for it any time soon. |
😭 thanks for the update. I will try to find a workaround (not using cy.task() in a origin) |
May I know if you will look for a solution or will this bug be there forever? |
If it can help, I now use a workaround with Previously: cy.origin('https://url/', () => {
cy.get(mySelector).find('a').then(($a) => {
const href: string = $a.prop('href');
cy.task('setItem', { name: 'reference', value: href });
});
}) and now with the "workaround": cy.origin('https://url/', () => {
cy.get(mySelector).find('a').invoke('attr', 'href')
}).then(($loc) => {
cy.task('setItem', { name: 'reference', value: $loc });
})
}) See https://docs.cypress.io/api/commands/origin#Yielding-a-value |
Description
When I updated the cypress version from 12.14 to 13.1 I get this error "Error: "cy.task() must only be invoked from the spec file or support file" when I try to use a command that contains the cy.task. Attached a basic error reproduction example
URL of Issue(s)
https://github.com/AndreanaCasilli/task-origin-error
Steps to replicate
within the repository the reproduction of the error
Browser
No response
Device
Additional Information
No response
The text was updated successfully, but these errors were encountered: