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.
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 have unit tests set up with Karma and Mocha. Karma is important here because some of the functionality I'm testing needs a web browser (even if a fake headless one). But much of the code can run either in a browser or Node.js. For debugging tests it would be much easier to skip launching Karma and use Mocha directly most of the time.
I can do that easily enough if running the whole test suite, but I'd like to be able to use the convenience of the little green play-button style arrows for individual tests. Unfortunately, even for a single unit test, these always launch Karma now.
Disabling the Karma plugin doesn't help. Instead, that makes all of the green arrows go away, with no easy access to either Karma or Mocha.
Is there a way to configure IDEA so that these convenience arrows ignore Karma, and directly run Mocha tests instead?
The logic used for determining what test runner is available for a given test file is based on dependencies declarations in package.json nearest to the current file.
Note that if you have a single package.json, with both karma and mocha included, and there is a karma config in your project, karma is preferred - see https://youtrack.jetbrains.com/issue/WEB-26070#comment=27-2088951. To force using Mocha test runner for files in a certain directory, create a Mocha run configuration with Test directory: set to this directory - when running tests from gutter in this folder, mocha will be used.
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.
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 just came into a Node.js project that has a ton of unit tests, most of which, unfortunately, are outdated and don't run. There's no test runner or any kind of code coverage tool implemented, and it is certainly not in my scope of work to refactor everything.
That being said, that doesn't stop me from wanting to check the code coverage of my work. I've looked at both Istanbul and Blanket and can't find a way to only have them run certain unit tests. Surely, there is a way so that I can get a report that, obviously, reports a very low percentage of coverage, but that I can dive into certain files and such (those that my tests hit) to ensure my code is throughly tested.
With istanbul.js, you can easily get the coverage information this by for example specifying the following command (Following example uses mocha but it will be similar for any test framework):
istanbul cover node_modules/.bin/_mocha -- -u exports -R spec test/test1.spec.js test/test2.spec.js
You can also specify all the tests in particular sub-directory eg: test/yourfeaturetest/*.spec.js. You also have something like test/myfeature/**/*.spec.js to cover all the tests in the test/myfeature directory including tests that could have been created recursively in sub-directories.
As for me, I use gulp and thus utilize plugins such as gulp-istanbul and run tests and coverage via gulp tasks.