forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collect coverage for jest itself (jestjs#1362)
- Loading branch information
1 parent
9beeee2
commit d8b14f8
Showing
5 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ website/src/jest/docs | |
website/src/jest/blog | ||
lerna-debug.log | ||
npm-debug.log* | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ node_js: | |
- "6" | ||
sudo: false | ||
before_install: npm i -g npm@latest | ||
script: | ||
- npm run test-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright (c) 2014, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Because we have a build step, sometimes we can test files from both | ||
* `packages/jest-whatever/build/*` and `packages/jest-whatever/src/*` | ||
* | ||
* If we require file by its relative path like: | ||
* // inside `jest-whatever/src/__tests__/index.js` | ||
* require('../index.js'); // this will require `jest-whatever/src/index.js` | ||
* | ||
* But if we require it by a package name, this will go through node_modules | ||
* and lerna index.js link. So the actual file will be required from `build/` | ||
* // inside another packages | ||
* // this will go through lerna and require `jest-whatever/build/index.js | ||
* require('jest-whatever') | ||
* | ||
* these files are identical (one is preprocessed, another is transformed on | ||
* the fly), but the coverage paths are different. | ||
* This script will map coverage results from both locations to one and | ||
* produce a full coverage report. | ||
*/ | ||
|
||
const createReporter = require('istanbul-api').createReporter; | ||
const coverage = require('../coverage/coverage-final.json'); | ||
const istanbulCoverage = require('istanbul-lib-coverage'); | ||
|
||
const map = istanbulCoverage.createCoverageMap(); | ||
const reporter = createReporter(); | ||
|
||
const mapFileCoverage = fileCoverage => { | ||
fileCoverage.path = fileCoverage.path | ||
.replace(/(.*packages\/.*\/)(build)(\/.*)/, '$1src$3'); | ||
return fileCoverage; | ||
}; | ||
|
||
Object.keys(coverage).forEach( | ||
filename => map.addFileCoverage(mapFileCoverage(coverage[filename])) | ||
); | ||
|
||
reporter.addAll(['json', 'lcov', 'text']); | ||
reporter.write(map); |