I have a built version of a React module that I'm testing successfully with Jasmine but when I try to use Istanbul to determine my tests coverage it shows that I'm only testing the Require.js Define lines of the code.
In particular the render function is clearly being called in my test (as I have tests that are passing on a div that must be being rendered) but is showing as not being covered in Istanbul.
Any ideas why this might be?
N.B. I am not testing the JSX files only their built JS versions.
Related
I've publish a tool which based on jest to test my code and collect coverage.
I found the same file's coverage in entire coverage report can't match single one file coverage report since I use v8 coverage provider.
This is my coverage of entire project.
It can't match the result that I run jest in single one file.
I think it maybe v8 coverage problem and also try out babel coverage, It seems OK.
So, the problems is that I can't remember why I use v8 instead of babel becuase leave on a warnning in my tool.
Is there any problems if I switch v8 to babel?
I am relatively new here and would need some help.
Company I work for uses karma and jasmine for unit testing.
Now they would like to migrate some tests to jest.
I got a ticket assigned to me. We are using typescript btw...
I got jest installed, prefixed with .spec.jest.ts to separate jest test from karmas. And it works fine. Jest just picks up those files that are prefixed. But when i try to do some build things we do with our project I get the type declaration conflicts between jest and jasmine.
For example: node_modules/#types/jest/index.d.ts:32:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: beforeAll, beforeEach, afterAll, afterEach, describe, fdescribe, xdescribe, it, fit, xit, expect, clock, DEFAULT_TIMEOUT_INTERVAL, CustomMatcherFact
ory, CustomEqualityTester
I am aware that jest is build on top of jasmine but is there some kind of workaround, we want to migrate our tests gradually. One at a time.
Is there some kind of workaround to namespace the types for jest or something like that so no conflicts occur?
Tnx in advance for your help :)
I tried to google some workaround but nothing that would solve the issue came across.
We excluded the karma types in the tsconfig and added jest types. The IDE now doesn't pick the karma types but it works for us since most of our tests are now in jest and very few left in karma and build process works now correctly since there are no more type conflicts.
WebStorm shows icons next to Jasmine's test cases and it seems as if there should be an option to run it, but the menu just says: Nothing here.
As I did not find any documentation about this feature, I wonder if it should be possible to run tests like this and if yes, what the conditions are.
This likely means that no suitable test runners have been found. WebStorm doesn't manage test running directly. This job is done by a test runner. WebStorm supports several test runners - Mocha, Karma, Jest, JsTestDriver, nodeunit,... The logic used for determining what test runner is available for a given test file is based on dependencies declarations in nearest package.json file.
I am trying to set up code coverage for my node.js unit tests.
What I am trying to do is this:
Use WebStorm for running tests
use Mocha (and co-mocha) as a testing framework
Use yield and generators for making my test code more readable
See the code coverage of my source code via the WebStorm UI (hoping to see my source code files color-coded according to code coverage)
The first two points are going fine, the third one is tripping me up.
Unfortunately WebStorm doesn't provide coverage support for Mocha:( Please follow WEB-10373 for updates
I'm using Jasmine as the testing framework for my AngularJS application. I run the tests with the help of Grunt & KarmaJS. KarmaJS also generates the code coverage with the help of karma-coverage.
Now I've created a model for configuaration data, which I also have to instantiate for other tests. Because of this instantiation I get a code coverage for this file although I haven't done any tests for it. Only because while the test run all of the lines were used, the coverage is 100%.
Now the question: Is there a way to specify in my tests which files they cover?
In PHP Unit there is an #covers annotation which specifies what code is covered with the test.
Thx
Since karma-coverage uses Istanbul under the hood, all configuration for Istanbul should work for karma-coverage.
In Istanbul, you can specify that a block of code be ignored for coverage purposes. You can try placing something like this at the top of your file:
/* istanbul ignore next */
I haven't tried this myself, but I'd bet that this or something similar would do what you want it to do.