mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
test_runner: support coverage of unnamed functions
This commit updates the code coverage logic to skip the first function in a file (which does not correspond to an actual function) instead of skipping all functions without a name. PR-URL: https://github.com/nodejs/node/pull/47652 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
ecb023be8a
commit
53e3c0ebf8
@ -155,7 +155,7 @@ class TestCoverage {
|
||||
});
|
||||
|
||||
for (let j = 0; j < functions.length; ++j) {
|
||||
const { functionName, isBlockCoverage, ranges } = functions[j];
|
||||
const { isBlockCoverage, ranges } = functions[j];
|
||||
|
||||
for (let k = 0; k < ranges.length; ++k) {
|
||||
const range = ranges[k];
|
||||
@ -172,7 +172,7 @@ class TestCoverage {
|
||||
}
|
||||
}
|
||||
|
||||
if (functionName.length > 0 && ranges.length > 0) {
|
||||
if (j > 0 && ranges.length > 0) {
|
||||
const range = ranges[0];
|
||||
|
||||
if (range.count !== 0 || range.ignoredLines === range.lines.length) {
|
||||
|
||||
2
test/fixtures/test-runner/coverage.js
vendored
2
test/fixtures/test-runner/coverage.js
vendored
@ -29,7 +29,7 @@ if (false) {
|
||||
require('./invalid-tap.js');
|
||||
}
|
||||
|
||||
test('a test', function testHandler() {
|
||||
test('a test', () => {
|
||||
const uncalled = () => {};
|
||||
|
||||
function fnWithControlFlow(val) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user