I have 2 questions about the (npx) cypress run
command.
- Inside the default Cypress pre-configured project, I created a file with a simple Cypress test (
cy.visit(...)
,cy.get(...)
,cy.should(...)
). However, the file either works or doesn't, depending on its extension:
npx cypress run --spec 'myTest.cy.js'
runs successfully.
npx cypress run --spec 'myTest.spec.js'
gives the following error:
Can't run because no spec files were found. We searched for specs matching this glob pattern: [correct/path/to/myTest.spec.js]
.js file extension gives the same error as .spec.js.
I saw many references using .spec.js as a correct file extension for Cypress to run single-file tests with the --spec
option.
Is there any additional configuration to make Cypress recognize it? The documentation I found doesn't make any distinction among .js files.
- Is the
cypress run
command able to take a path with spaces? One of my computer drives has a spaced name I can't modify, and usingcypress run
inside it gives the same error as in 1., with Cypress removing the quotes around the path to display it in the error.
I am using the latest Cypress version, 11.2.0.
CodePudding user response:
From what I have read in the docs, Ref
Option Default Description specPattern cypress/e2e/**/*.cy.{js,jsx,ts,tsx} A String or Array of glob patterns of the test files to load.
the .cy.js
extension is the default for specs (for Cypress version, 11.2.0), and if you want to use something else you must configure it explicitly in `cypress.config.js.
Of course you can use spaces on the command line, but you must surround the value that contains the spaces with quote marks. This is because the space char is the delimiter char on any command line command, not just with Cypress.