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

chore(cypress): upgrade to [email protected] #27

Merged
merged 2 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ I'm using [cypress.io](https://www.cypress.io/) for the e2e tests. You will find

<p align="center"><a href="https://twitter.com/topheman/status/989856595436867584"><img src="https://raw.githubusercontent.com/topheman/npm-registry-browser/master/public/cypress-screenshot-small.png" width="300" /></a></p>

When you add a spec file, reference it in [cypress/integration/index.spec.js](cypress/integration/index.spec.js) (specific to my [cypress.json](cypress.json) config, explained bellow).

#### [email protected] upgrade

Since `[email protected]`, each spec file runs in isolation. The tests took much longer to run.

To speed them up, I decided to run all the files in the same spec (tests don't rely on state of previous state - they could be ran in isolation if needed).

[A message is output](cypress/support/precyrun.js) to explain how to run them in a regular way:

* remove [cypress/integration/index.spec.js](cypress/integration/index.spec.js)
* update [cypress.json](cypress.json), remove the `testFiles` entry.

## Linter

I use eslint to check the coding style, with the following presets:
Expand Down
5 changes: 3 additions & 2 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"baseUrl": "http://localhost:5000",
"videoRecording": false,
"video": false,
"chromeWebSecurity": false,
"projectId": "8r5nf4"
"projectId": "8r5nf4",
"testFiles": "**/index.spec.js"
}
5 changes: 5 additions & 0 deletions cypress/integration/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "./home.spec";
import "./package.spec";
import "./qrcode.spec";
import "./search.spec";
import "./searchResults.spec";
16 changes: 16 additions & 0 deletions cypress/support/precyrun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file is called on "precy:run" script
console.log(`
= Running all test files in the same spec ==========================================================

Since [email protected], each spec file runs in isolation. The tests took much longer to run.

To speed them up, I decided to run all the files in the same spec.

When creating a new spec file, update cypress/integration/index.spec.js, add your file.

If you want to revert to the regular usage:
- remove cypress/integration/index.spec.js
- update cypress.json, remove the "testFiles" entry.

────────────────────────────────────────────────────────────────────────────────────────────────────
`);
135 changes: 76 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
"test:cypress:dev": "npm-run-all --parallel --race start 'cy:open -- --config baseUrl=http://localhost:3000'",
"test:cypress:debug-build": "npm run build && cross-env CYPRESS_LAUNCH_MODE=debug-build npm-run-all --parallel --race serve cy:open",
"cy:open": "cypress open",
"precy:run": "node cypress/support/precyrun.js",
"cy:run": "cypress run",
"cy:run:travis": "npm run cy:run -- --record --config videoRecording=true",
"cy:run:travis": "npm run cy:run -- --record --config video=true",
"cy:start-server-and-test": "npx start-server-and-test serve :5000 cy:run",
"cy:start-server-and-test:travis": "npx start-server-and-test serve :5000 cy:run:travis",
"test:precommit": "npm test",
Expand All @@ -92,7 +93,7 @@
"commander": "^2.15.1",
"cors-anywhere": "^0.4.1",
"cross-env": "^5.1.4",
"cypress": "^2.1.0",
"cypress": "^3.0.1",
"cypress-testing-library": "^1.0.1",
"dom-testing-library": "^1.9.0",
"enzyme": "^3.3.0",
Expand Down