Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit 444ebc1

Browse files
committed
Cypress test: Add option for testing without build and deploy
Sometimes, we don't want Cypress to rebuild and redeploy the application every time we run the tests. Instead, we build and deploy the application ourselves. For those cases, we can use npm run cypress:local:testonly and Cypress will skip building and deployment and move directly into testing.
1 parent 31b0f09 commit 444ebc1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cypress/plugins/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ module.exports = (on, config) => {
4343
on('task', {
4444
// Check if deployment is currently active
4545
isDeployed: () => {
46+
if(config.env.SKIP_DEPLOY === true)
47+
return true
48+
4649
return config.activeDeployment !== null
4750
},
4851
})

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
],
2727
"scripts": {
2828
"test": "jest --config tests/jest.config.js",
29-
"cypress:local": "env CYPRESS_DEPLOY=local cypress run --config-file false",
30-
"cypress:netlify": "env CYPRESS_DEPLOY=netlify cypress run --config-file false"
29+
"cypress:local": "env CYPRESS_DEPLOY=local cypress run --config-file false",
30+
"cypress:netlify": "env CYPRESS_DEPLOY=netlify cypress run --config-file false",
31+
"cypress:local:testonly": "env CYPRESS_SKIP_DEPLOY=true npm run cypress:local",
32+
"cypress:netlify:testonly": "env CYPRESS_SKIP_DEPLOY=true npm run cypress:netlify"
3133
},
3234
"devDependencies": {
3335
"cypress": "^4.6.0",

0 commit comments

Comments
 (0)