You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
2 years ago | |
---|---|---|
.. | ||
cypress | 2 years ago | |
.gitignore | 2 years ago | |
README.md | 2 years ago | |
cypress.json | 2 years ago | |
demo.gif | 2 years ago | |
package-lock.json | 2 years ago | |
package.json | 2 years ago | |
server.js | 2 years ago |
README.md
Prevent push when skipping Cypress tests
Make sure your Cypress testing pipeline never let's you push broken code when accidentally skipping tests.
Setup
git clone https://git.peterbabic.dev/demo/cypress-prevent-push-skips.git
cd cypress-prevent-push-skips
npm install
How does it work
Edit spec.js, add .skip or .only modifier to the test or tests and try to push any committed changes this way to the repository. The push shooed fail due to pre-push hook, that makes sure that the push fails in two situations:
- Any test contains .skip or .only, which means not all of them would be executed
- Any test fails, step 1 endures all tests are executed
The detection happens in the package.json
grep -Rvzq -e '.skip' -e '.only' cypress/integration
More details described in the blog post located at:
https://peterbabic.dev/blog/prevent-push-when-skipping-cypress-tests
Preventing the behavior
The push can be executed even with skipping or failing tests by supplying
--no-verify
git push origin master --no-verify
Possible improvements
Currently, the message provided looks like this:
$ git push origin master
husky > pre-push (node v14.9.0)
husky > pre-push hook failed (add --no-verify to bypass)
error: failed to push some refs to 'git.peterbabic.dev:demo/cypress-prevent-push-skips.git'
However, it is not clear why the pre-push hook failed. The verbosity could be improved.
License
MIT