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.

Statements detected are not the same in unit-tests context

See original GitHub issue

Hi,

Currently, I use babel-plugin-istanbul to get code coverage after my E2E tests (selenium). The global variable in my browser window.__coverage__ is correctly filled but for a lot of files, the statements detected are not the same when I execute my unit-tests.

For example, when I generate lcov report for my unit-tests (from nyc mocha), each “import” lines are seen as statement but in my browser in window.__coverage__ variable, these lines are not seen as statement. Consequently, when I try to merge lcov files generated by my unit-tests and by my E2E tests I have a crash (see below)…

C:\Users\me\AppData\Roaming\npm\node_modules\istanbul\lib\object-utils.js:247 for (i = 0; i < retArray.length; i += 1) { ^ TypeError: Cannot read property 'length' of undefined

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gigagacommented, Sep 20, 2017

@bcoe Hi. You can find my fork here : https://github.com/gigaga/babel-plugin-istanbul-issue In this fork, there are 2 ways to compute code coverage from my unit-tests:

  • npm run test-babel-plugin-istanbul: where coverage is computed with babel-plugin-istanbul
  • npm run test-nyc: where coverage is computed with nyc

The coverages are generated into “results\coverage” folder. You can see that the statements detected are not the same. For example, for nyc, the first line of reducer.jsx is seen as statement where as this same line for babel-plugin-istanbul is not a statement.

1reaction
gigagacommented, Sep 17, 2017

I thinks that the merge process is not the problem. My problem is why some statements are not detected by babel-plugin-istanbul whereas these same statements are detected with nyc / mocha (without the plugin)? If statements are the same, there will be no merge problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

unittest — Unit testing framework — Python 3.11.1 ...
These methods are used instead of the assert statement so the test runner can accumulate all test results and produce a report. The...
Read more >
Mockito Tests Pass individually but fail as part of a suite
Reason: your test load one application context with bean mock inside. The bean mocks are dirty after any test. You have a dirty...
Read more >
Understanding the Python Mock Object Library - Real Python
In this tutorial, you'll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your...
Read more >
Python Mocking: A Guide to Better Unit Tests - Toptal
How to Run Unit Tests in Python Without Testing Your Patience. More often than not, the software we write directly interacts with what...
Read more >
Right Way to Test, Mock, and Patch in Python - Medium
The unittest.mock module: Mock Object Library ... use case for this is for mocking the objects used as context managers in a with...
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