Home > Enterprise >  Limiting run to only one file does not work
Limiting run to only one file does not work

Time:04-18

I just installed Cypress and was test running it.

Running npm run cy-run will run all test files which takes quite a lot of time and can become confusing.

Note that I have not added a single test of mine. The tests are the default examples coming from Cypress installation.

When attempting to limit to a single file I found several sources - including enter image description here

CodePudding user response:

Instead of trying to run this from the command line, rather just - while writing and running your tests - prefix the only chain to it.

Example, change this:

it("should do stuff", () => ...);

to this:

it.only("should do stuff", () => ...);

You can add this to describe.only as well if you want to run a whole suite - or in your case, file - alone.

Another Option:

If you'd like to only run tests that you've written, you can either just remove all those example files or change describe to xdescribe or it to xit and cypress will skip running those specified tests.

Command Line Solution:

You're missing --, add that in and it should work as per your solution.

It should be written like this:

npm run cy-run -- --spec cypress/integration/2-advanced-examples/viewport.spec.js
  • Related