question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to auto-start the first spec file in the list (add option to cypress open)

See original GitHub issue

What would you like?

Hi there, I am very close to being able to run a GUI cypress test with a single click from vscode. Here’s how that happens currently:

image

I use an extension https://marketplace.visualstudio.com/items?itemName=shevtsov.vscode-cy-helper that adds the “Open Cypress” text above each it block. Upon clicking that, this code runs in the vscode terminal:

npx cypress open --e2e --browser chrome --config specPattern="/Users/tnrich/Sites/openVectorEditor/cypress/e2e/tabs.spec.js"

That command in turn opens up the cypress gui to a page that looks like: image

What I’m asking for is an additional option on cypress open, something like --auto-start or auto-run or auto-start-first-spec

The entire command would then look like:

npx cypress open --auto-start --e2e --browser chrome --config specPattern="/Users/tnrich/Sites/openVectorEditor/cypress/e2e/tabs.spec.js"

And then the first (and in my case only) matching spec file would start running immediately on startup instead of me having to click another button.

I hope that all makes sense.

Why is this needed?

Having the ability to click once to run a test is very powerful. This would be a useful feature for all cypress users and make cypress testing even easier.

Other

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tnrichcommented, Aug 10, 2022

Well I have to join the Cypress’ dev point of view in case of the issue https://github.com/cypress-io/cypress/issues/3665 😛 (I don’t see that much value in having “watchForFileChanges” work in run mode).

I generally disagree with that as do many others judging by the number of upvotes in that thread.

When you want to start a single test with either npx “cypess open” or “cypress run” you’d still loose time because Cypress is started every time for only a single spec

The startup time for the new cypress v10 for me on an m1 macbook is negligible. The ability to just click one button (from vscode specifically) is paramount to me. If it didn’t have to restart the cypress runner each time a new spec was clicked that would be fine (and was thus even faster on subsequent runs), but the single button click to get to a running test is the KEY feature for me.

Hope the above points make sense. I appreciate the back and forth @mirobo!

Cheers!

1reaction
mirobocommented, Aug 10, 2022

Wouldn’t it be an option to let the plugin execute this command instead? npx cypress run --headed --e2e --browser chrome --config specPattern="/Users/tnrich/Sites/openVectorEditor/cypress/e2e/tabs.spec.js"

or maybe with added “–no-exit” so the UI stays open and the test could be re-run? npx cypress run --headed --no-exit --e2e --browser chrome --config specPattern="/Users/tnrich/Sites/openVectorEditor/cypress/e2e/tabs.spec.js"

Also I don’t really see the benefit in starting Cypress with only one spec. You could just open Cypress normally and then click on the respective test to start it (ok, it’s not started from the IDE though). It will be much faster since Cypress is already open

https://docs.cypress.io/guides/guides/command-line#cypress-run

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practices - Cypress Documentation
Best Practice: Test specs in isolation, programmatically log into your application, and take control of your application's state. In February 2018 we gave...
Read more >
Cypress - automatically run all tests in browser, with hot reload
If you run Cypress tests headlessly cypress run it runs all tests without the need to click the "Run all tests" button.
Read more >
Testing an API with Cypress - CircleCI
Learn how to set up Cypress and configure it to run API tests. ... First, create an empty directory and initialize an empty...
Read more >
End-to-end testing with Cypress series: 02 Getting Started
and open it in your preferred text editor. 05:53: Cypress uses Mocha.js' BDD syntax for writing spec files. 05:58: Add a describe call...
Read more >
Cypress Studio - the underrated feature speeding up e2e testing
When the Cypress Test Runner is open, enter our test file and click the tiny blue magic wand that says Add Commands to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found