Skip to content

Commit 538d4da

Browse files
author
Benjamin E. Coe
authored
fix: support [email protected] built-in modules (bcoe#265)
1 parent 9dd30c2 commit 538d4da

File tree

4 files changed

+46
-41
lines changed

4 files changed

+46
-41
lines changed

.nycrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"html",
44
"text"
55
],
6-
"lines": 96,
6+
"lines": 95,
77
"branches": "82",
8-
"statements": "96"
9-
}
8+
"statements": "95"
9+
}

lib/report.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ class Report {
258258
_normalizeProcessCov (v8ProcessCov, fileIndex) {
259259
const result = []
260260
for (const v8ScriptCov of v8ProcessCov.result) {
261+
// https://github.com/nodejs/node/pull/35498 updates Node.js'
262+
// builtin module filenames:
263+
if (/^node:/.test(v8ScriptCov.url)) {
264+
v8ScriptCov.url = `${v8ScriptCov.url.replace(/^node:/, '')}.js`
265+
}
261266
if (/^file:\/\//.test(v8ScriptCov.url)) {
262267
try {
263268
v8ScriptCov.url = furi.toSysPath(v8ScriptCov.url)

test/integration.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ All files | 64.29 | 66.67 | 50 | 64.29 |
9191
--------------|---------|----------|---------|---------|-------------------
9292
,ERROR: Coverage for lines (64.29%) does not meet global threshold (100%)
9393
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
94-
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
94+
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
9595
"
9696
`;
9797

9898
exports[`c8 --all should allow for --all to be used with the check-coverage command (2 invocations) 1`] = `
9999
",,ERROR: Coverage for lines (64.29%) does not meet global threshold (90%)
100100
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
101-
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
101+
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
102102
"
103103
`;
104104

@@ -146,23 +146,23 @@ All files | 83.33 | 85.71 | 60 | 83.33 |
146146
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
147147
-----------|---------|----------|---------|---------|-------------------
148148
,ERROR: Coverage for lines (83.33%) does not meet global threshold (101%)
149-
ERROR: Coverage for statements (83.33%) does not meet global threshold (96%)
149+
ERROR: Coverage for statements (83.33%) does not meet global threshold (95%)
150150
"
151151
`;
152152

153153
exports[`c8 check-coverage allows threshold to be applied on per-file basis 1`] = `
154154
",,ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js
155155
ERROR: Coverage for lines (75%) does not meet threshold (101%) for test/fixtures/normal.js
156156
ERROR: Coverage for branches (66.67%) does not meet threshold (82%) for test/fixtures/normal.js
157-
ERROR: Coverage for statements (75%) does not meet threshold (96%) for test/fixtures/normal.js
157+
ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixtures/normal.js
158158
"
159159
`;
160160

161161
exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`;
162162

163163
exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = `
164164
",,ERROR: Coverage for lines (83.33%) does not meet global threshold (101%)
165-
ERROR: Coverage for statements (83.33%) does not meet global threshold (96%)
165+
ERROR: Coverage for statements (83.33%) does not meet global threshold (95%)
166166
"
167167
`;
168168

@@ -250,7 +250,7 @@ All files | 83.33 | 85.71 | 60 | 83.33 |
250250
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
251251
-----------|---------|----------|---------|---------|-------------------
252252
,ERROR: Coverage for lines (83.33%) does not meet global threshold (101%)
253-
ERROR: Coverage for statements (83.33%) does not meet global threshold (96%)
253+
ERROR: Coverage for statements (83.33%) does not meet global threshold (95%)
254254
"
255255
`;
256256

test/integration.js_10.snap

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ covered
1616
--------------------------|---------|----------|---------|---------|--------------------------------
1717
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
1818
--------------------------|---------|----------|---------|---------|--------------------------------
19-
All files | 76.3 | 61.9 | 68.57 | 76.3 |
19+
All files | 76.18 | 61.18 | 68.57 | 76.18 |
2020
bin | 78.85 | 60 | 66.67 | 78.85 |
2121
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
22-
lib | 80.89 | 53.7 | 84.21 | 80.89 |
22+
lib | 80.67 | 52.73 | 84.21 | 80.67 |
2323
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
2424
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
25-
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
25+
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
2626
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
2727
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
2828
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -102,14 +102,14 @@ All files | 64.29 | 66.67 | 50 | 64.29 |
102102
--------------|---------|----------|---------|---------|-------------------
103103
,ERROR: Coverage for lines (64.29%) does not meet global threshold (100%)
104104
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
105-
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
105+
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
106106
"
107107
`;
108108

109109
exports[`c8 --all should allow for --all to be used with the check-coverage command (2 invocations) 1`] = `
110110
",,ERROR: Coverage for lines (64.29%) does not meet global threshold (90%)
111111
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
112-
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
112+
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
113113
"
114114
`;
115115

@@ -140,13 +140,13 @@ hey
140140
--------------------------|---------|----------|---------|---------|--------------------------------
141141
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
142142
--------------------------|---------|----------|---------|---------|--------------------------------
143-
All files | 75.81 | 59.49 | 67.65 | 75.81 |
143+
All files | 75.69 | 58.75 | 67.65 | 75.69 |
144144
bin | 78.85 | 60 | 66.67 | 78.85 |
145145
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
146-
lib | 80.89 | 53.7 | 84.21 | 80.89 |
146+
lib | 80.67 | 52.73 | 84.21 | 80.67 |
147147
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
148148
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
149-
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
149+
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
150150
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
151151
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
152152
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -155,44 +155,44 @@ All files | 75.81 | 59.49 | 67.65 | 75.81 |
155155
async.js | 100 | 100 | 100 | 100 |
156156
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
157157
--------------------------|---------|----------|---------|---------|--------------------------------
158-
,ERROR: Coverage for lines (75.81%) does not meet global threshold (101%)
159-
ERROR: Coverage for branches (59.49%) does not meet global threshold (82%)
160-
ERROR: Coverage for statements (75.81%) does not meet global threshold (96%)
158+
,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
159+
ERROR: Coverage for branches (58.75%) does not meet global threshold (82%)
160+
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
161161
"
162162
`;
163163

164164
exports[`c8 check-coverage allows threshold to be applied on per-file basis 1`] = `
165165
",,ERROR: Coverage for lines (78.85%) does not meet threshold (101%) for bin/c8.js
166166
ERROR: Coverage for branches (60%) does not meet threshold (82%) for bin/c8.js
167-
ERROR: Coverage for statements (78.85%) does not meet threshold (96%) for bin/c8.js
167+
ERROR: Coverage for statements (78.85%) does not meet threshold (95%) for bin/c8.js
168168
ERROR: Coverage for lines (21.31%) does not meet threshold (101%) for lib/commands/check-coverage.js
169-
ERROR: Coverage for statements (21.31%) does not meet threshold (96%) for lib/commands/check-coverage.js
169+
ERROR: Coverage for statements (21.31%) does not meet threshold (95%) for lib/commands/check-coverage.js
170170
ERROR: Coverage for lines (93.1%) does not meet threshold (101%) for lib/commands/report.js
171171
ERROR: Coverage for branches (71.43%) does not meet threshold (82%) for lib/commands/report.js
172-
ERROR: Coverage for statements (93.1%) does not meet threshold (96%) for lib/commands/report.js
172+
ERROR: Coverage for statements (93.1%) does not meet threshold (95%) for lib/commands/report.js
173173
ERROR: Coverage for lines (90%) does not meet threshold (101%) for lib/is-cjs-esm-bridge.js
174174
ERROR: Coverage for branches (25%) does not meet threshold (82%) for lib/is-cjs-esm-bridge.js
175-
ERROR: Coverage for statements (90%) does not meet threshold (96%) for lib/is-cjs-esm-bridge.js
175+
ERROR: Coverage for statements (90%) does not meet threshold (95%) for lib/is-cjs-esm-bridge.js
176176
ERROR: Coverage for lines (96.13%) does not meet threshold (101%) for lib/parse-args.js
177177
ERROR: Coverage for branches (45.45%) does not meet threshold (82%) for lib/parse-args.js
178-
ERROR: Coverage for lines (75.44%) does not meet threshold (101%) for lib/report.js
179-
ERROR: Coverage for branches (61.76%) does not meet threshold (82%) for lib/report.js
180-
ERROR: Coverage for statements (75.44%) does not meet threshold (96%) for lib/report.js
178+
ERROR: Coverage for lines (75.17%) does not meet threshold (101%) for lib/report.js
179+
ERROR: Coverage for branches (60%) does not meet threshold (82%) for lib/report.js
180+
ERROR: Coverage for statements (75.17%) does not meet threshold (95%) for lib/report.js
181181
ERROR: Coverage for lines (44%) does not meet threshold (101%) for lib/source-map-from-file.js
182-
ERROR: Coverage for statements (44%) does not meet threshold (96%) for lib/source-map-from-file.js
182+
ERROR: Coverage for statements (44%) does not meet threshold (95%) for lib/source-map-from-file.js
183183
ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js
184184
ERROR: Coverage for lines (75%) does not meet threshold (101%) for test/fixtures/normal.js
185185
ERROR: Coverage for branches (66.67%) does not meet threshold (82%) for test/fixtures/normal.js
186-
ERROR: Coverage for statements (75%) does not meet threshold (96%) for test/fixtures/normal.js
186+
ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixtures/normal.js
187187
"
188188
`;
189189

190190
exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`;
191191

192192
exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = `
193-
",,ERROR: Coverage for lines (75.81%) does not meet global threshold (101%)
194-
ERROR: Coverage for branches (59.49%) does not meet global threshold (82%)
195-
ERROR: Coverage for statements (75.81%) does not meet global threshold (96%)
193+
",,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
194+
ERROR: Coverage for branches (58.75%) does not meet global threshold (82%)
195+
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
196196
"
197197
`;
198198

@@ -264,13 +264,13 @@ exports[`c8 report generates report from existing temporary files 1`] = `
264264
",--------------------------|---------|----------|---------|---------|--------------------------------
265265
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
266266
--------------------------|---------|----------|---------|---------|--------------------------------
267-
All files | 75.81 | 59.49 | 67.65 | 75.81 |
267+
All files | 75.69 | 58.75 | 67.65 | 75.69 |
268268
bin | 78.85 | 60 | 66.67 | 78.85 |
269269
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
270-
lib | 80.89 | 53.7 | 84.21 | 80.89 |
270+
lib | 80.67 | 52.73 | 84.21 | 80.67 |
271271
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
272272
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
273-
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
273+
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
274274
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
275275
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
276276
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -286,13 +286,13 @@ exports[`c8 report supports --check-coverage, when generating reports 1`] = `
286286
",--------------------------|---------|----------|---------|---------|--------------------------------
287287
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
288288
--------------------------|---------|----------|---------|---------|--------------------------------
289-
All files | 75.81 | 59.49 | 67.65 | 75.81 |
289+
All files | 75.69 | 58.75 | 67.65 | 75.69 |
290290
bin | 78.85 | 60 | 66.67 | 78.85 |
291291
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
292-
lib | 80.89 | 53.7 | 84.21 | 80.89 |
292+
lib | 80.67 | 52.73 | 84.21 | 80.67 |
293293
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
294294
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
295-
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
295+
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
296296
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
297297
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
298298
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -301,9 +301,9 @@ All files | 75.81 | 59.49 | 67.65 | 75.81 |
301301
async.js | 100 | 100 | 100 | 100 |
302302
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
303303
--------------------------|---------|----------|---------|---------|--------------------------------
304-
,ERROR: Coverage for lines (75.81%) does not meet global threshold (101%)
305-
ERROR: Coverage for branches (59.49%) does not meet global threshold (82%)
306-
ERROR: Coverage for statements (75.81%) does not meet global threshold (96%)
304+
,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
305+
ERROR: Coverage for branches (58.75%) does not meet global threshold (82%)
306+
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
307307
"
308308
`;
309309

0 commit comments

Comments
 (0)