Skip to content

Commit a6a45ed

Browse files
committed
Expose cypress's --spec pattern option from yarn and therefore rake
I had a need to run the following locally: CYPRESS=true SPEC=cypress/e2e/ui/Settings/Application-Settings/tenant.cy.js bundle exec rake spec:cypress You could specify a directory to run all cypress tests within it: CYPRESS=true SPEC=cypress/e2e/ui/Settings/Application-Settings bundle exec rake spec:cypress Or a pattern: CYPRESS=true SPEC=cypress/e2e/ui/**/settings* bundle exec rake spec:cypress In case you wanted to test specific file name patterns, like below: ``` % tree . ... │ ├── Settings │   └── Application-Settings │   ├── c_and_u_gap_collection.cy.js │   ├── edit_collect_logs.cy.js │   ├── schedule.cy.js │   ├── settings_access_control.cy.js # <--- Want to test │   ├── settings_details_tab.cy.js # <--- ^ │   ├── tenant.cy.js │   └── zone.cy.js ├── settings.cy.js # <--- ^ ├── validate-intercept-api-command.cy.js └── validate-select-accordion-item.cy.js ``` This could have been done in the Rakefile but yarn should expose this so it can be used for example, in CI, by setting environment variables. This solution allows it's usage from both rake and yarn directly. Note, rspec also has a SPEC env variable that is used in the same way to specify a pattern for finding tests, see: https://github.com/rspec/rspec/blob/22549bbf4723ff893339d5233482894d33a24819/rspec-core/lib/rspec/core/rake_task.rb#L122
1 parent fbd8102 commit a6a45ed

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
],
1313
"scripts": {
1414
"cypress:open": "cypress open",
15-
"cypress:run:chrome": "cypress run --headless --browser chrome",
16-
"cypress:run:edge": "cypress run --headless --browser edge",
17-
"cypress:run:firefox": "cypress run --headless --browser firefox",
15+
"cypress:run:chrome": "cypress run --headless --browser chrome ${SPEC:+--spec \"$SPEC\"}",
16+
"cypress:run:edge": "cypress run --headless --browser edge ${SPEC:+--spec \"$SPEC\"}",
17+
"cypress:run:firefox": "cypress run --headless --browser firefox ${SPEC:+--spec \"$SPEC\"}",
1818
"test": "jest",
1919
"test:watch": "jest --watchAll",
2020
"test:current": "jest --watch",

0 commit comments

Comments
 (0)