cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Proposal: Launch single cypress test from vscode

Open tnrich opened this issue 6 years ago • 13 comments

It would be awesome to be able to run a single cypress test in the cypress devtool directly from vscode. Currently something like that exists for debugging a jest test:

image

As seen in the above photo, a user can hit "debug" and launch a debugging session for an individual jest test. I think it would be super awesome if I could press a "run cypress" button from the editor and have the devtool launch just that test.

In order to get that feature to work I think a few things would need to be done:

  • programmatic launching of a single test file using the cypress open command (not currently available according to https://docs.cypress.io/guides/guides/command-line.html#cypress-open). This would look like cypress open mySpec.js

  • programmatic running of just 1 test within a file (NOTE: Not Essential as this can already be done using it.only and is potentially a complicated issue, see https://github.com/cypress-io/cypress/issues/925)

  • actually making the cypress vscode plugin to put it all together!

I'd love to hear other people's thoughts on this. I just think it could make the already excellent cypress workflow even better!

Thanks!

tnrich avatar Jan 10 '19 00:01 tnrich

I would love to see a proper jest runner so that we could script all tests (jest and Cypress) via a runner and use npm run test or npx jest to just run all tests and integration tests. Would that feature make it possible? It would require Cypress to be able to communicate it's output to jest/external not only to std out as far as I remember.

ethernal avatar Jan 13 '19 21:01 ethernal

@ethernal I don't think what you're suggesting is necessary for what I want to do. While it would technically solve what I'm trying to do, I think it should probably opened as a separate issue to this one.

tnrich avatar Feb 05 '19 22:02 tnrich

Could anyone guide me as to how to implement this:

  • programmatic launching of a single test file using the cypress open command (not currently available according to https://docs.cypress.io/guides/guides/command-line.html#cypress-open). This would look like cypress open mySpec.js

tnrich avatar Feb 21 '19 01:02 tnrich

@tnrich There is an issue open to add support for --spec argument to cypress open https://github.com/cypress-io/cypress/issues/1925

jennifer-shehane avatar Feb 21 '19 14:02 jennifer-shehane

Okay I've created a v1 of the vscode extension vscode-extension-open-cypress

cypressOpen

https://github.com/tnrich/vscode-extension-open-cypress

https://marketplace.visualstudio.com/items?itemName=tnrich.vscode-extension-open-cypress

I've added a TODO list for the features that I think would make this extension actually be really cool:

  • [ ] not just open but also be able to AUTOMATICALLY run a spec file (requires cypress team to add a way to make all specs run upon open or a single spec run on open)
  • [ ] add a .only to the it() block that the cursor is in (alternatively cypress team should add a way to grep to run a single it block IMO)

@jennifer-shehane @bahmutov if you guys could help me figure out a way to have cypress run automatically that would be awesome! I think the need to grep to run a single it block is less important because I can just manually add a .only() to the it block and save (which is a little messy but fine).

tnrich avatar Aug 15 '19 16:08 tnrich

'Run Test | Debug Test' in a test spec.js file in order to run / debug a cypress test in VSCode is a must.

What's the status of this work in the Cypress dev group?

PiotrNestor avatar Nov 05 '19 13:11 PiotrNestor

I've created a similar plugin for IDEA (with JS support only) It allows running a single test, a spec or all tests in a directory from IDE directly (and see test statuses as well) https://plugins.jetbrains.com/plugin/13819-intellij-cypress

mbolotov avatar Feb 20 '20 14:02 mbolotov

Debugging from VSCode by simply setting a breakpoint is a must.

AlexA-1976 avatar Jul 01 '20 20:07 AlexA-1976

Yeah, it'd be ideal to have this feature delivered to help the extensions be more helpful. https://github.com/cypress-io/cypress/issues/1925

There are some workaround in there, like using the testFiles config to narrow down the specs shown in the list, but yah - wouldn't open and run directly.

jennifer-shehane avatar Jul 02 '20 05:07 jennifer-shehane

Christ, 3 years and there's still no way to make any meaningful editor extensions. Please, for the love of god, don't misinterpret the original issue as a request for the Cypress team to develop extensions, you're merely asked to expose more fine-grained control over runner. It's literally a no-brainer and nothing to agonize over.

badeball avatar Jun 24 '22 22:06 badeball

@jennifer-shehane bump on this one.. still waiting for a way to be able to launch and RUN a test directly from my editor.

tnrich avatar Jan 30 '23 17:01 tnrich

@jennifer-shehane A year later, would still love to see some way of making this happen.. anyone have any news on this? @emilyrohrbough @chrisbreiding :)

tnrich avatar Jan 18 '24 21:01 tnrich

haha gonna bump this another year later. still waiting on an easy way to launch a spec from vscode.. would be truly awesome to have this still

thanks in advance!

@jennifer-shehane @mschile @cacieprins

tnrich avatar Feb 28 '25 00:02 tnrich