-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use source-map-fixtures to get a fixture file with an inline source map. Add a script to generate a coverage report for this specific fixture. Rewrite tests to use the fixture, without (too much) hardcoding of values. This will make it easier to upgrade the fixture in the future, as well as regenerate the coverage report. It does break the babel tests. Will fix that in the next commit.
- Loading branch information
1 parent
7d1fb6a
commit d4c42b3
Showing
7 changed files
with
201 additions
and
6,222 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
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,48 @@ | ||
'use strict' | ||
|
||
// Generates the test/fixtures/coverage.js file, not otherwise used in the | ||
// tests. | ||
|
||
var fs = require('fs') | ||
var path = require('path') | ||
|
||
var _ = require('lodash') | ||
var rimraf = require('rimraf') | ||
|
||
var NYC = require('../../') | ||
|
||
// Load the 'branching' source map fixture. | ||
var fixture = require('source-map-fixtures').inline('branching') | ||
|
||
// Prevent pollution from earlier nyc runs. | ||
var tempDirectory = path.join(__dirname, '.nyc_output') | ||
rimraf.sync(tempDirectory) | ||
|
||
// Inject nyc into this process. | ||
var nyc = (new NYC({ | ||
cwd: path.join(__dirname, '..', '..'), | ||
tempDirectory: tempDirectory | ||
})).wrap() | ||
// Override the exclude option, source-map-fixtures is inside node_modules but | ||
// should not be excluded when generating the coverage report. | ||
nyc.exclude = [] | ||
|
||
// Require the fixture so nyc can instrument it, then run it so there's code | ||
// coverage. | ||
fixture.require().run() | ||
|
||
// Write the coverage file so reports can be loaded. | ||
nyc.writeCoverageFile() | ||
|
||
var reports = _.values(nyc._loadReports()[0]) | ||
if (reports.length !== 1) { | ||
console.error('Expected 1 report to be generated, got ' + reports.length) | ||
process.exit(1) | ||
} | ||
|
||
var coverage = reports[0] | ||
fs.writeFileSync( | ||
path.join(__dirname, 'coverage.js'), | ||
'// Generated using node test/fixtures/_generateCoverage.js\n' + | ||
'exports[' + JSON.stringify(coverage.path) + '] = ' + JSON.stringify(coverage, null, 2) + '\n') | ||
console.log('Written coverage report.') |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.