-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 list of search patterns in testFiles config option #5402
Conversation
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
path.join(cfg.projectRoot, "cypress", "integration", "js_spec.js") | ||
]) | ||
] | ||
specsUtil.find(cfg, specPattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
being a little bit clearer on the arguments
.then (files) -> | ||
expect(files.length).to.equal(1) | ||
expect(files[0].name).to.equal("js_spec.js") | ||
|
||
it "filters using specPattern as array of glob patterns", -> | ||
config.get(FixturesHelper.projectPath("various-file-types")) | ||
.then (cfg) -> | ||
specsUtil.find(cfg, [ | ||
debug("test config testFiles is %o", cfg.testFiles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a few debug statements to the test itself is useful when iterating on the test and understanding what is going on
.tap((files) => { | ||
return debug('found %d spec files: %o', files.length, files) | ||
}) | ||
return Promise.mapSeries(testFilesPatterns, findOnePattern).then(_.flatten) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find matching spec files one pattern at a time and then merging them
Change `testFiles` from a string to either a string **or** array of strings; following similar pattern as `ignoreTestFiles`
See paulmillr/chokidar#855 for more details.
it "runs project by limiting spec files via config.testFiles as an array of string glob patterns", -> | ||
cypress.start(["--run-project=#{@todosPath}", "--config=testFiles=**/test2.coffee,**/test1.js"]) | ||
.then => | ||
expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, {url: "http://localhost:8888/__/#/tests/integration/test2.coffee"}) | ||
.then => | ||
expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, {url: "http://localhost:8888/__/#/tests/integration/test1.js"}) | ||
@expectExitWith(0) | ||
|
||
it "runs project by limiting spec files via config.testFiles as an array of string glob patterns", -> | ||
cypress.start(["--run-project=#{@todosPath}", "--config='[\"testFiles=**/test2.coffee\",\"**/test1.js\"]'"]) | ||
.then => | ||
expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, {url: "http://localhost:8888/__/#/tests/integration/test2.coffee"}) | ||
.then => | ||
expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, {url: "http://localhost:8888/__/#/tests/integration/test1.js"}) | ||
@expectExitWith(0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh my
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retract my assessment. It looks like we do not need the functionality in that PR. Furthermore, supporting the syntax --config=testFiles=["**/*.js", "**/*.coffee"]
is how other mutli-value config values work; such as ignoreTestFiles. I do not see any documentation or elsewhere in tests indicating that the format, --config=testFiles=**/*.js,**/*.coffee
, is actually supported.
Distinguish between the two tests; as they are subtly different.
@@ -43,7 +43,7 @@ declare module 'cypress' { | |||
*/ | |||
reporter: string, | |||
/** | |||
* A String glob pattern of the test files to load. | |||
* A String or Array of string glob pattern of the test files to load. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got to update the type here as well
testFiles: string | string[]
Updated the comments, but forgot to update the actual type. This commit rectifies that.
`--config` was not being passed the appropriate value. Now matches other test cases; such as that found in [args_spec](https://github.com/cypress-io/cypress/blob/92b91fe514e5ff6286b4d4e26d2df23062bdf869/packages/server/test/unit/args_spec.coffee#L210)
From looking at other tests, it does not appear that the syntax `--config=testFiles=glob1,glob2` is current supported. Removing the test for this test case.
@@ -322,9 +322,18 @@ describe "lib/config", -> | |||
@setup({testFiles: "**/*.coffee"}) | |||
@expectValidationPasses() | |||
|
|||
it "fails if not a string", -> | |||
it "passes if an array of strings", -> | |||
@setup({ignoreTestFiles: ["**/*.coffee", "**/*.jsx"]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean testFiles
here right ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, let me change these two places within config_spec
@expectValidationFails("be a string or an array of string") | ||
|
||
it "fails if not an array of strings", -> | ||
@setup({ignoreTestFiles: [5]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean testFiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see two comments in tests
Previously was testing `ignoreTestFiles` instead of `testFies`
Content updates due ot changes in [PR](cypress-io/cypress#5402)
Should be a string or an array of strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accept that wording change if you want. but LGTM
make sure to merge in develop and rebuild after we get this circle zip file size figured out |
Co-Authored-By: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
* update docs to reflect changes to `testFiles` Content updates due ot changes in [PR](cypress-io/cypress#5402) * examples of multi-value config properties via CLI Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
User facing changelog
testFiles
which follows the principle inignoreTestFiles
config optionAdditional details
Using
glob
to select several groups of spec names is not obvious. For example to select both.md
and*spec.js
files one would need to write without spacesWith this change, user could write
which to me looks more natural and easier to remember. Also added debug log messages during
DEBUG=cypress:server:specs
that show how the search happens in case on needs to debug it.How has the user experience changed?
PR Tasks
cypress-documentation
? Issue 2183 cypress-documentation#2184type definitions
?cypress.schema.json
?