-
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
before:spec broken? #22360
Comments
Hi @ciprianene , thank you for reporting! I put together this repo to reproduce your issue. It looks like you found a buggo! 🐛 Observed behavior:
Expected behavior: Documentation |
Just to add my team's use case here - we are trying to load in some data during test loading (we wrapped Mocha's Right now we're loading in all possible required files since we can't get the specific spec during interactive mode, which we anticipate will become a performance bottleneck as our test suite grows (approx 10-15sec per 1000 data files according to my testing). |
Interesting that this appears to be in open mode only. Investigating now.
This is quite different from run mode, where all information is properly available: |
Ok, so looking into it, this is the intended behavior. From our docs:
I can see a very good argument that this is dumb behavior -
Correction: It looks to be a regression, since it did work properly in pre-10.x versions of Cypress. Looks like it got overlooked during the upgrade. The difference is that opening the browser used to be synonymous with running a particular spec. |
So I'm at a bit of a standstill here. Our docs say that the plugin's before:spec can return a promise which will be awaited. However, my current approach was to tap into mocha events - runner:start and runner:end - and mocha events are synchronous. You can't delay execution based on them. So my options are...
|
So I've stopped working on this for now; Anyone else who wants to take a look is welcome. Also copying a bit of conversation I had with @emilyrohrbough here for future reference - she has good ideas on what events we should hook into, rather than my attempt to listen to mocha run:start / run:stop events.
|
The code for this is done in cypress-io/cypress#23634, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
When trying to run a "before:spec" function, nothing happens.
Desired behavior
No response
Test code to reproduce
setupNodeEvents(on, config) {
on("before:spec", (spec) => {
console.log("Running before spec: ", { spec });
});
}
(//experimentalInteractiveRunEvents is set to true.)
the log will return empty values for the spec object.
Also logged what's returned by before:run and the spec shows as an empty array.
Cypress Version
10.1.0
Other
No response
The text was updated successfully, but these errors were encountered: