Jest 16: coverage empty with collectCoverageFrom
See original GitHub issueHi,
Iāve just upgraded to jest 16, and since my test coverage are empty.
If I remove the collectCoverageFrom
option from the config it seams to works š³
Apart from that, loving the new features šKeep it up š»
"collectCoverageFrom": [
"<rootDir>/src/main/webapp/scripts/**/*.js"
],
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files | Unknown | Unknown | Unknown | Unknown | |
----------|----------|----------|----------|----------|----------------|
=============================== Coverage summary ===============================
Statements : Unknown% ( 0/0 )
Branches : Unknown% ( 0/0 )
Functions : Unknown% ( 0/0 )
Lines : Unknown% ( 0/0 )
================================================================================
jest version = 16.0.0
test framework = jasmine2
config = {
"preprocessorIgnorePatterns": [
"node_modules"
],
"modulePaths": [
"MYPATH/src/main/webapp/scripts"
],
"moduleNameMapper": [
[
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$",
"MYPATH/src/test/javascript/file-mock.js"
],
[
"^.+\\.(css|less)$",
"MYPATH/src/test/javascript/style-mock.js"
]
],
"testPathDirs": [
"MYPATH/src/main/webapp/scripts"
],
"testResultsProcessor": "MYPATH/node_modules/jest-teamcity-reporter",
"collectCoverageFrom": [
"MYPATH/src/main/webapp/scripts/**/*.js"
],
"coverageThreshold": {
"global": {
"branches": 95,
"functions": 95,
"lines": 95,
"statements": 95
}
},
"rootDir": "MYPATH",
"name": "-MYNAME",
"testRunner": "MYPATH/node_modules/jest-jasmine2/build/index.js",
"scriptPreprocessor": "MYPATH/node_modules/babel-jest/build/index.js",
"usesBabelJest": true,
"automock": false,
"bail": false,
"browser": false,
"cacheDirectory": "/var/folders/x3/142j64696f11fhmkr3f2q6g42rxg89/T/jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"haste": {
"providesModuleNodeModules": []
},
"mocksPattern": "__mocks__",
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"node"
],
"modulePathIgnorePatterns": [],
"noStackTrace": false,
"notify": false,
"preset": null,
"resetModules": false,
"testEnvironment": "jest-environment-jsdom",
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
"testURL": "about:blank",
"timers": "real",
"useStderr": false,
"verbose": null,
"watch": false,
"collectCoverage": true,
"cache": false,
"watchman": true,
"testcheckOptions": {
"times": 100,
"maxSize": 200
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Not able to collect coverage in Jest - Stack Overflow
I tried using "collectCoverageFrom" : ["**/src/**/*.js"] but it throws me Unknown for all params. Am I missing something here? jest-setup.json:
Read more >Configuring Jest for Next.JS (React) and Babel from scratch
Step 3: Create the configuration files. Let's begin with 'package.json'. You'll add the following nodes under āscriptā: test, test:coverage, devĀ ...
Read more >Configuring Jest
You can collect coverage from those files with setting forceCoverageMatch . ... it will be present in the object with its value set...
Read more >Configuring Jest compiled - w3resource
Because it retrofits all executed files with coverage collection statements, this mayslow down your test significantly slow. collectCoverageFrom ...
Read more >Configuring Jest to show code coverage for all of your files
exports = { collectCoverage: true, collectCoverageFrom: ['src/**/*.{js,jsx}'], };. Now all you would have to do is runĀ ...
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 Free
Top 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
Itās quite confusing that
collectCoverageFrom
must not containrootDir
while others must use it.If you remove
<rootDir>
should work since itās relative from root:Another issue I found is that the command-line argument
--collectCoverageFrom
is ignored if a config file is provided, even without that option:jext-config.json:
UPDATE I could be wrong, but I noticed that the client argument is a string, but looks like the same config option expects an array
UPDATE 2 Even though the
normalize
takes care of the type, the argv option is discard later on.