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

Added Jest coverage configuration #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions tutorial/02-babel-es6-eslint-flow-jest-husky.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,25 @@ test('Dog.bark', () => {
})
```

- Add `jest` to your `test` script:
- Add `jest` to your `test` script and configure jest coverage to monitor any js file in the src directory/subdirectories:

```json
"scripts": {
"start": "babel-node src",
"test": "eslint src && flow && jest --coverage"
},
"jest":{
"testEnvironment": "node",
"collectCoverageFrom": [
"src/**/*js"
]
}
```

The `--coverage` flag makes Jest generate coverage data for your tests automatically. This is useful to see which parts of your codebase lack testing. It writes this data into a `coverage` folder.

- Add `/coverage/` to your `.gitignore`

🏁 Run `yarn test`. After linting and type checking, it should run Jest tests and show a coverage table. Everything should be green!
🏁 Run `yarn test`. After linting and type checking, it should run Jest tests and show a coverage table. Files that pass will be shown in green. Notice index.js is red, this is jest's coverage working for us as we have not created a test file for index.js.

## Git Hooks with Husky

Expand Down