cypress run --spec cypress/integration/APP/**/* runs all tests instead of just subfolder APP tests

Created on 31 May 2018  Β·  8Comments  Β·  Source: cypress-io/cypress

Is this a Feature or Bug?

Bug

Current behavior:

I have two subfolders in my integration folder:
cypress/integration/APP/
cypress/integration/API/

When I run

cypress run --spec cypress/integration/APP/*/

ALL tests run, but I expected that only tests in the APP subfolder would run.
Is this a bug or intended behaviour? Doesn't the --spec flag support globs?

Desired behavior:

Just run tests in cypress/integration/APP/ subfolder
The --spec feature would be really useful if I could run all tests in different subfolders so I could manually distribute tests across machines.

Steps to reproduce:

cypress run --spec cypress/integration/SUBFOLDER/**/*

Versions

cypress 3.0.1 on Mac OS 10.13.4

question

Most helpful comment

@silversteez @maximilianschmid try adding single quotes around the spec glob or use an equals sign...

cypress run --spec 'cypress/integration/test/**/*'
cypress run --spec=cypress/integration/test/**/*

All 8 comments

You should see new output we added in 3.0 that specifies Specs and Searched

Specs being the specs that will be run
Searched being what Cypress used to search for the specs

screen shot 2018-05-31 at 12 37 13 pm

What is printed in these fields in the console output?

You can run different subfolders by passing multiple globs to the spec argument like:

cypress run --spec cypress/integration/APP/**/*,cypress/integration/API/**/*

I just ran mine for a subfolder and it did work for me. Double check your glob with a glob tester.

If it's still not working, let me know what terminal you are using.

$ ./node_modules/.bin/cypress run --spec cypress/integration/examples/**/*


====================================================================================================

  (Run Starting)

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Cypress:    3.0.0                                                                              β”‚
  β”‚ Browser:    Electron 59 (headless)                                                             β”‚
  β”‚ Specs:      19 found (examples/actions.spec.js, examples/aliasing.spec.js, examples/assertion… β”‚
  β”‚ Searched:   cypress/integration/examples/**/*                                                  β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Thanks for your helpful response.
I further investigated this issue. I'm using the original Mac OS Terminal.

cypress run --spec cypress/integration/API/*/

Output:
β”‚ Cypress: 3.0.1
β”‚ Browser: Electron 59 (headless)
β”‚ Specs: 199 found (_reset-to-fixtures.spec.js, API/crm/task-crm-test-end.spec.js, API/doc…
(1 of 199)

BUT when adding a trailing comma to the glob only tests in API folder run, so it works as expected:

cypress run --spec cypress/integration/API/*/,

Output:
β”‚ Cypress: 3.0.1
β”‚ Browser: Electron 59 (headless)
β”‚ Specs: 125 found (API/crm/task-crm-test-end.spec.js, API/documents/acl_GET_all.spec.js, …
β”‚ Searched: cypress/integration/API/*/,
(1 of 125)

Tested with locally installed cypress (npm i cypress) and globally installed cypress (npm i cypress -g) - both show the same behaviour.

So adding a trailing comma to the glob works for me and is ok for me as workaround.

Just want to chime in to say I had the same issue and adding the trailing comma got it working for me. (Thanks @maximilianschmid)

  "scripts": {
    "cypress:open": "cypress open",
    "cypress:run": "cypress run --spec cypress/integration/test/**/*,"
  },

@silversteez @maximilianschmid try adding single quotes around the spec glob or use an equals sign...

cypress run --spec 'cypress/integration/test/**/*'
cypress run --spec=cypress/integration/test/**/*

@brian-mann Yup, both of those work for me, as well. Thanks.

@brian-mann both solutions work form me as well. thx.

Checkout your documentation to reflect this solutions:
https://docs.cypress.io/guides/guides/command-line.html#Run-tests-specifying-a-glob-of-where-to-look-for-test-files

We updated the documentation last week and I'm going to close this issue.

Was this page helpful?
0 / 5 - 0 ratings