Callback not reported as not called
- 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
Assessment
This issue has not been assessed yet.