Skip to content
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

Group tests to improve performance by reducing the amount of page loads #2943

Closed
Lakitna opened this issue Dec 13, 2018 · 4 comments
Closed
Labels
stage: proposal 💡 No work has been done of this issue type: enhancement Requested enhancement of existing feature

Comments

@Lakitna
Copy link
Contributor

Lakitna commented Dec 13, 2018

Current behavior:

When you want to improve runtime by reducing page loads you have to order your tests by their run order, even if that doesn't make sense from a logical standpoint.

I want to use Cypress to test a single page application that's different based on the parameters with which it's loaded. In this case, the parameters are userId and authorization. The application can get pretty complex so I order my test files by the part of the application they are testing. In some cases, properly testing the part of the application under test requires reloading the application with different parameters.

That also means that in my current implementation I'm reloading the page 50+ times, about 35 of which are the exact same page with the same userId and authorization. That's pretty wasteful.

Desired behavior:

I want to be able to specify groups of tests across files that run with a single shared before script. That would allow me to set up the page in the before script and run my tests on that one instance of the application, greatly reducing the number of repeated steps required for running the suite.

Thinking I could control the Mocha instance of Cypress I wrote a Mocha UI to solve this problem. This package accurately describes the desired behaviour for me.

I've been asking about a way to accomplish this on Gitter but I didn't get a response, that probably means there is no way to do this yet.

Versions

Cypress 3.1.3
Windows 7
Chrome 70

@Lakitna Lakitna changed the title Bundle tests to improve performance by reducing the amount of page loads Group tests to improve performance by reducing the amount of page loads Dec 13, 2018
@jennifer-shehane
Copy link
Member

Hey @Lakitna, Cypress allows you to define a global before, beforeEach, afterEach, and after within the support files.

We definitely encourage you to extend and add onto Cypress as needed. The bundle concept in the Mocha UI looks pretty useful.

Is there an issue when you try to run the bundle UI with Cypress?

@Lakitna
Copy link
Contributor Author

Lakitna commented Dec 13, 2018

I haven't gotten the UI working but that might be because of the old Mocha version in Cypres 3.x. I'll try getting things working on the 4.0 branch.

If that's not the solution I frankly don't know where to look to implement this since I can't reach the mocha options of the Cypress Mocha instance as far as I'm aware. For reporters, the options are exposed. But for other stuff, it's not.

@Lakitna
Copy link
Contributor Author

Lakitna commented Dec 13, 2018

So update time. I've been able to get the UI to show up in global.Mocha.interfaces allowing me to call mocha.ui('BDD-bundle'). However, this does not allow me to change the Mocha UI after it has been instantiated during Cypress' startup.

It comes basically down to the issue that I can't change the Mocha UI of Cypress without forking it.

I can see two options to enable test grouping:

  • One is you guys providing more control over the Mocha UI, allowing me to use the one linked before.
  • The other is writing a preprocessor that bundles everything and moves the tests into their proper place. However, this would be completely new territory for me and quite frankly seems like an overkill solution with loads of pittfalls and bug potential.

If anyone has got any other suggestions I would love to hear them!

@jennifer-shehane
Copy link
Member

Closing this feature request since it hasn’t gotten a lot of interest over the years. We’ve more recently inteoduced cy.session, which will run some set of commands in a session then reload the state of the App to that session. It may achieve what was originally asked here in some cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: proposal 💡 No work has been done of this issue type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

2 participants