Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing a list of glob patterns in testFiles config option #5401

Closed
bahmutov opened this issue Oct 21, 2019 · 7 comments · Fixed by #5402
Closed

Allow passing a list of glob patterns in testFiles config option #5401

bahmutov opened this issue Oct 21, 2019 · 7 comments · Fixed by #5402
Assignees

Comments

@bahmutov
Copy link
Contributor

Cypress v3.4.1

There is a configuration option testFiles in https://on.cypress.io/configuration that controls which spec files are found.
Let's say I have the following files

cypress/
	integration/
		foo.js
		bar.js
		baz.js

If I want to only have "foo.js" file I can do the following

{
  "testFiles": "foo.js"
}

But how do I pick "foo.js" AND "bar.js"?

I would be very nice to allow testFiles to be a single string or a list of strings and match each filename against a list.

@bahmutov
Copy link
Contributor Author

Example repo in https://github.com/cypress-io/cypress-test-tiny/tree/test-files

@bahmutov
Copy link
Contributor Author

This would be super useful for JS specs + Markdown fiddles in cypress-io/cypress-fiddle#21 where I need to select a pattern of spec filenames AND all markdown files

@bahmutov
Copy link
Contributor Author

We could follow the example of ignoreTestFiles: v.isStringOrArrayOfStrings (config.coffee) and update testFiles to be similar

@bahmutov bahmutov self-assigned this Oct 21, 2019
@bahmutov
Copy link
Contributor Author

Since we use glob under the hood (should note this in our configuration docs), then to select two files one should use

{
  "testFiles": "{foo,bar}.js"
}

and you can see the spec finding messages by running Cypress with DEBUG=cypress:server:specs environment variable

@bahmutov
Copy link
Contributor Author

Note that there should be no spaces in the pattern. To find all files with extension .md AND ending with spec.js one needs to do

{
  "testFiles": "{*.md,*spec.js}",
}

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 31, 2019

The code for this is done in cypress-io/cypress#5402, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Oct 31, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 5, 2019

Released in 3.6.0.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants