How can i run tests before commit using lint-staged and react-scripts?
See original GitHub issueCurently have
"devDependencies": {
"husky": "^0.13.3",
"lint-staged": "^3.4.2",
"prettier": "^1.3.1",
"react-scripts": "1.0.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"precommit": "lint-staged"
},
"lint-staged": {
"src/**/*.js": [
"prettier",
"git add"
]
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
setting up lint-staged for jest - Stack Overflow
There is a work around to set husky lint-staged using react-scripts test and avoid ejecting and configuring your own babel and jest.
Read more >Husky + Lint-Staged on a React TypeScript Project
To trigger some action before committing, we will use the Git Hook called “pre-commit”. Let's now create an action to execute our 'test'...
Read more >Build a robust React app with Husky pre-commit hooks and ...
Adding a pre-commit hook with Husky and lint-staged In our hook, we will check for linter errors and warnings, type errors, failing tests,...
Read more >Lint Staged With Husky for Pre-commit Validations - YouTube
Learn how to use lint staged with husky to implement linting and formatting your code with Prettier and Eslint on pre - commit....
Read more >Automated Code Linting and Testing | by Harsh Verma - Medium
Script test:staged — By default the react-scripts run the test cases in watch mode but this will hang such type of CI(Continous Integration) ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@spacecrio this is how I implement it
then
for the env variable, use cross-env… it is cross platform
hope it helps!
without passing
CI=true
jest will automatically run in watch mode by default. so it’s not suitable for testing staged files.IMO until this time, doing like what I wrote in the comment before is perfectly fine. Also by passing
--findRelatedTests
will make things faster because jest (under the hood) will find related tests and run selected tests based on files which are currently in staging area.