Open steveguerrero opened 1 year ago
@steveguerrero 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.
Also check out the Cypress Discord Community , it can be helpful for debugging or answering questions on how to use Cypress.
@nagash77 Thanks for your answer. I created a fork from Cypress Test Tiny and I really appreciate your quick reply
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
Did you find a possible solution or workaround? @jennifer-shehane
i also am getting this error, running on Ubuntu 22.04 and Node v20.10.0 with Yarn 4.1.1:
Error:
Expected DataContext to already have been set via setCtx. If this is a
testing context, make sure you are calling "setCtx" in a before hook,
otherwise check the application flow.
at c (<embedded>:4315:138737)
at Object.u (<embedded>:4359:75697)
at Object.<anonymous> (<embedded>:4392:28989)
at Object.tryCatcher (~/.cache/Cypress/13.8.1/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
at Object.execute (~/.cache/Cypress/13.8.1/Cypress/resources/app/node_modules/bluebird/js/release/method.js:15:34)
at C.close (<embedded>:4450:26869)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Havin the same issue, where the delete function that should be executed after:run
won't get executed when closing the runner - same error:
Error:
Expected DataContext to already have been set via setCtx. If this is a
testing context, make sure you are calling "setCtx" in a before hook,
otherwise check the application flow.
at c (<embedded>:2746:138737)
at Object.u (<embedded>:2790:77126)
at Object.<anonymous> (<embedded>:2823:28750)
at Object.tryCatcher (~/Library/Caches/Cypress/13.12.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
at Object.execute (~/Library/Caches/Cypress/13.12.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:15:34)
at C.close (<embedded>:2881:26880)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Me too, same issue when closing Cypress window without running any browser.
on('after:run', async () => {
console.debug('In after run.');
});
Error:
Expected DataContext to already have been set via setCtx. If this is a
testing context, make sure you are calling "setCtx" in a before hook,
otherwise check the application flow.
at c (<embedded>:2746:138779)
at Object.u (<embedded>:2790:79114)
at Object.<anonymous> (<embedded>:2823:28750)
From previous event:
at C.close (<embedded>:2881:26880)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Current behavior
In our project we use cypress in interactive mode and trying to use the after run api to run a delete function after the tests run.
As described in the cypress documentation we use the flag experimentalInteractiveRunEvents in our config.
If you run the interactive mode the after run api doesn't trigger the delete function but displays an error message after closing the Cypress client:
"Error:
Expected DataContext to already have been set via setCtx. If this is a testing context, make sure you are calling "setCtx" in a before hook, otherwise check the application flow."
Desired behavior
The After Run API should trigger when the user closes the browser or probably even better on closing the Cypress client
Test code to reproduce
Cypress Version
12.17.1
Node version
v18.16.1
Operating System
Windows 10 Enterprise 21H219044.3086
Debug Logs
No response
Other
No response