bcoe / bcoe/c8

Callback not reported as not called

Open
#208 3 comments 1 reaction 0 assignees View on GitHub
bug more-info-needed v8
Dominant language
JavaScript
Stars
2.1k
Forks
99
PR merge metrics
No merged PRs in 30d

Description

* **Version**: c8 7.1.0
* **Platform**: node.js v13.11.0, Linux x86_64 installed by nvm

The following script demonstrates the problem:
```js
const arr = ['value'];

console.log('longest to shortest:', ...arr.sort((a, b) => { console.log('sort'); return b.length - a.length; }));
```

Running `npx c8 node script.js` outputs:
```
longest to shortest: value
-----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
script.js | 100 | 100 | 100 | 100 |
-----------|---------|----------|---------|---------|-------------------
```

The `console.log('sort')` was just added for debug to show that the callback to `arr.sort` is not called when sorting an array of less than 2 entries. In this case I expected c8 to report that function coverage is not 100%.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.