-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experimental): Support using
--all
with node.js ES modules
This allows `--all` to collect initial coverage from fils which node.js recognizes as ES modules (`.mjs` files and conditionally `.js` files). Previously this would cause node.js to produce an `ERR_REQUIRE_ESM` error. This does not enable collection of coverage during actual tests, for that you must use the experimental `@istanbuljs/esm-loader-hook`.
- Loading branch information
1 parent
086fd20
commit 169d04e
Showing
10 changed files
with
156 additions
and
11 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,79 @@ | ||
function cov_2h0lluvd0i() { | ||
var path = "/usr/src/npm/nyc/test/fixtures/all-type-module/extra-pre.mjs"; | ||
var hash = "d6f47486f9f4ee6194d9e4a0c8a93f6a6a4ef1fc"; | ||
var global = new Function("return this")(); | ||
var gcv = "__coverage__"; | ||
var coverageData = { | ||
path: "/usr/src/npm/nyc/test/fixtures/all-type-module/extra-pre.mjs", | ||
statementMap: { | ||
"0": { | ||
start: { | ||
line: 2, | ||
column: 1 | ||
}, | ||
end: { | ||
line: 2, | ||
column: 20 | ||
} | ||
} | ||
}, | ||
fnMap: { | ||
"0": { | ||
name: "(anonymous_0)", | ||
decl: { | ||
start: { | ||
line: 1, | ||
column: 15 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 16 | ||
} | ||
}, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 27 | ||
}, | ||
end: { | ||
line: 3, | ||
column: 1 | ||
} | ||
}, | ||
line: 1 | ||
} | ||
}, | ||
branchMap: {}, | ||
s: { | ||
"0": 0 | ||
}, | ||
f: { | ||
"0": 0 | ||
}, | ||
b: {}, | ||
_coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9", | ||
hash: "d6f47486f9f4ee6194d9e4a0c8a93f6a6a4ef1fc" | ||
}; | ||
var coverage = global[gcv] || (global[gcv] = {}); | ||
|
||
if (!coverage[path] || coverage[path].hash !== hash) { | ||
coverage[path] = coverageData; | ||
} | ||
|
||
var actualCoverage = coverage[path]; | ||
{ | ||
// @ts-ignore | ||
cov_2h0lluvd0i = function () { | ||
return actualCoverage; | ||
}; | ||
} | ||
return actualCoverage; | ||
} | ||
|
||
cov_2h0lluvd0i(); | ||
export default function () { | ||
cov_2h0lluvd0i().f[0]++; | ||
cov_2h0lluvd0i().s[0]++; | ||
return 'es module'; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImV4dHJhLXByZS5tanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQWVZOzs7Ozs7Ozs7QUFmWixlQUFlLFlBQVk7QUFBQTtBQUFBO0FBQzFCLFNBQU8sV0FBUDtBQUNBIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gKCkge1xuXHRyZXR1cm4gJ2VzIG1vZHVsZSc7XG59XG4iXX0= |
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,3 @@ | ||
export default function () { | ||
return 'es module'; | ||
} |
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,3 @@ | ||
export default function () { | ||
return 'es module'; | ||
} |
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,10 @@ | ||
{ | ||
"name": "all-type-module", | ||
"version": "0.1.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"nyc": { | ||
"all": true | ||
} | ||
} |
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,5 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
// Not doing anything, we just want something to run with `nyc --all` | ||
process.exit(0); |
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