cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

Run single spec example does not work

Open bnjmn opened this issue 3 years ago • 2 comments

Subject

Guides

Description

I am trying to follow the guide on how to run a single spec file (great for use during development of that spec). However, the example provided does not work for me and I wonder if this is a regression with the recent upgrades.

The section on this page shows the following examples:

npm run cy:run --record --spec "cypress/e2e/my-spec.cy.js"
npx cypress run --record --spec "cypress/e2e/my-spec.cy.js"

However, only the latter works for me (with npx). When I run the command with the npm script it collects all my specs and runs them.

Current version:

  • node 16.14
  • npm 8.5
  • cypress 10.3.0

Please update the guide or fix the issue. Not sure what is going on. Thanks.

image

bnjmn avatar Sep 01 '22 17:09 bnjmn

I just figured it out. You need to add -- after the script target like so,

npm run cy:run -- --record --spec "cypress/path/to/spec.cy.js"

An update would be great and may avoid some confusion from others. Thanks!

bnjmn avatar Sep 01 '22 18:09 bnjmn

A pull request has been added for this here

bnjmn avatar Sep 01 '22 18:09 bnjmn

This has been updated 🙏

jaffrepaul avatar Apr 06 '23 20:04 jaffrepaul