question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is the code coverage markup working properly?

See original GitHub issue

I’m a bit confused by the code coverage highlighting. Is it working as expected? /cc @bookman25?

Here’s the HTML reporter compared to our overlay: 2017-12-05 -- vscode-jest - code coverage annotations

Steps to Reproduce

Here’s the repo for the example:

git clone https://github.com/seanpoulter/issue--jest-community--vscode-jest--181

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bookman25commented, Dec 9, 2017

I’m all in favor of adding more tests. I’m not attached to any of the code. If you find a way to improve the code so it makes more sense and is easier to maintain, then by all means feel free.

1reaction
seanpoultercommented, Dec 8, 2017

@bookman25, are you OK if I refactor overlay.ts as a class so it’s easier to test? I’m just getting familiar with Jest’s mocking, but it seems let testing a lot easier to manage mocks when you’re checking behavior (e.g.: callFoo() calls foo().

// module.test.ts
import m from './module'

it('calls foo', () => {
  (m.foo as any) = jest.fn()
  m.callFoo()
  expect(m.foo).toBeCalled()      // Nope: Expected mock function to have been called
})

it('is not a mock', () => {
  expect(m.foo.mock).not.toBeDefined()   // Nope: Expected value not to be ... a mock!
})


// class.ts: OK
import { C } from './class'

it('calls foo', () => {
  const c = new C()
  c.foo = jest.fn()
  c.callFoo(args)
  expect(c.foo).toBeCalledWith(args)
})

it('is not a mock', () => {
  const c = new C()
  expect(c.foo.mock).not.toBeDefined()
})

Full disclosure: That’s how I’ve been adding tests but I wanted to check in before I bother with a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Everything you need to know about code coverage - Codegrip
Code coverage is a software testing metric that can help in assessing the test performance and quality aspects of any software.
Read more >
How to read code coverage report - YouTube
We will look at code coverage HTML report generated after Cypress test run, and I will explain the line counters, if/else branching and...
Read more >
Reviewing Coverage Information - Parasoft C++test 10.3.3 ...
Statement Coverage. Indicates how many executable source code statements were reached by the control flow at least once. Complete, 100% ...
Read more >
Conflicting Code Coverage Results - Salesforce Developers
The coverage markup in the left hand column is clearly incorrect - there's no way that you can cover a comment line for...
Read more >
Clearing coverage highlighting in Eclipse - java - Stack Overflow
Eclemma is maintained, but does not work properly with some unit testing framework features of Mockito and Powermock. So basicly it has problems...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found