-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cypress Run - Do not relaunch browser in between each spec file #2951
Comments
Reloading the Cypress runner for each spec is intended behavior - and a recent change made in Cypress 3.0 that you can read about in more detail here: #681 |
Similar to #2943 I'd say |
@jennifer-shehane Has the team evaluated the option that instead of killing the browser completely, we could add a new tab to it then close the previous tab? I figure that at least we could save the time and resources that the browser needs when it initialize the first time. |
Seconding this - Any chance to execute the new spec into another tab? Cheers |
or can someone at least suggest a way to avoid having 10000 tests in one file? can we split them between files without killing the whole browser in between? |
what if we want to maintain the state of the application, instead of launching new tab which may cause to lose the state? For example, I login to the app. (My app is huge). Now after I login, i have many e2e tests in different spec files. And once all of my tests are done, I logout from the app. But i dont want to relaunch the browser/tab and lose the state. Have you thought of this use case ? |
@sagar-ag05 We're working on a session API that should help with this use case. #8301 |
@jennifer-shehane - What is the timeline of session API availability? |
@renelux - How are you combining/importing diff spec file into index_spec.js file ? |
+100 to this feature. I have 100s of tests split up logically into spec files, which is useful to a) avoid a single, massive spec file and b) to allow me to run a single spec at a time if needed. But when running all the tests (definitely in CI, but also locally sometimes) I don't need the browser to restart after each spec, and it adds a ton of time. My tests are relatively simple - parallelism and user sessions would be overkill, or not applicable. I just need a way to run multiple spec files without killing the browser between each one! |
@mcintyret - Just curious to know if you have grouped just single test under each spec file? |
I'm with @mcintyret on this one - I've got about a dozen spec files (expected to grow rapidly), each testing a specific page in our app, and if I execute |
It seems Cypress 10 brings the same behaviour to component tests, which is even more problematic. |
@pmk1c Component Testing in 10.0 now uses the same code path as E2E. This did indeed slow things down, but improve spec isolation... I'm looking at some perf improvements, follow #22353 for more info. As for the original feature request - as of Cypress 10, both E2E and CT now use 1 browser, a new tab per spec, so I'd say this feature (as in, the original request) is ✔️, which should solve some performance issues. This isn't the end - we are always looking to making things faster - just the end of the "single browser per run" issue. The experimental session API also landed. See the docs: https://docs.cypress.io/api/commands/session I'm going to close this since both requests (single tab, sessions) are implemented. |
Hi René Lux, |
He is just doing something like /** cypress.config.js */
export default defineConfig({
e2e: {
specPattern: 'cypress/e2e/**/*.spec.js'
}
}) /** cypress/e2e/all_specs.spec.js */
import './spec-1.js'
import './spec-2.js'
import './spec-3.js' Making 1 spec file that imports the others, so Cypress only launches once (for the 1 spec file). Not sure this is ideal, but it answers the question you are asking (what did the user do). Most likely you'll want a different |
In our current project we have around 40 spec files with tests for different components or pages. The Cypress pipeline on our CI takes around 12-13 min. Instead of just throwing more server resources at it and paralyze the runs we looked into how we could improve the runtime by doing some optimizations.
We noticed that for every spec file it reloads the Cypress runner, this takes up some time which might not be necessary.
Our current solution is to create a
index_spec.js
that dynamically imports all other spec files in that folder. This cuts the runtime down with around 4-5 minutes, but this doesn't work well with plugins likecypress-plugin-snapshots
as they use the spec files path to generate the path to store the snapshots.Would it be possible to have the
run
command support a way to bundle specs?The text was updated successfully, but these errors were encountered: