collectCoverageFrom didn't work in react components
See original GitHub issue🐛 Bug Report
when i set jest config in package.json like this
"jest": {
"verbose": true,
"collectCoverage": true,
"globals": {},
"testEnvironment": "jest-environment-jsdom-global",
"moduleFileExtensions": [
"js",
"jsx",
"json"
],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
},
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileTransformer.js"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/"
],
"setupFiles": [
"jest-canvas-mock"
],
"testMatch": [
"<rootDir>/**/*.(test|spec).js"
],
"coverageDirectory": "<rootDir>/test/unit/coverage",
"collectCoverageFrom": [
"<rootDir>/**/util.js"
],
"coveragePathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/test",
"<rootDir>/tasks",
"<rootDir>/config"
]
},
when i run yarn run jest
, i get this
To Reproduce
Expected behavior
is should only collect util.js , but it collect react components, i set react components test
it('renders correctly', () => {
expect(toJson(wrapper)).toMatchSnapshot();
});
is this impact collectCoverageFrom
Link to repl or repo (highly encouraged)
sorry,i can’t provided it
envinfo
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Binaries:
Node: 10.15.3
Yarn: 1.16.0
npm: 6.4.1
npmPackages:
jest:
wanted: ^23.2.0
installed: 23.6.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Jest collectCoverageFrom and coverageThreshold not working
This means when I run npm t jest must show me error about global coverage does not 100%. But I don't see any...
Read more >Jest collectCoverageFrom and coverageThreshold not ...
Coding example for the question Jest collectCoverageFrom and coverageThreshold not working-Reactjs.
Read more >Configuring Jest
collectCoverageFrom [array]. Default: undefined. An array of glob patterns indicating a set of files for which coverage information should be collected. If a ......
Read more >React unit test and code coverage with Jest and Istanbul
Configuring Jest to run React Tests ... Step 2: Bring in npm dependencies: ... Step 4: Write your component: // File location: app/components/App.js...
Read more >Configuring Code Coverage for TypeScript Files in Jest
In this lesson I demonstrate using the collectCoverageFrom ... a Utility File for Rendering Redux Connected React Components in Tests.
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
i have update jest 24.9.0 version, it also has this problem.
the problem is collectCoverageFrom didn’t work. i set jest config
collectCoverageFrom: ['<rootDir>/**/util.js']
so i want to collect Coverage the files named ‘util.js’ , but it collect all the filescollectCoverageFrom
still doesn’t collect coverage for React components? I’m trying it with"src/**/*.{ts,tsx}"
and it indeed doesn’t cover React components. 🤷🏻♂️