Wrong Jest package in Intellij IDEA run configuration detected - testing

I want to run the tests of my frontend project, but everytime I want to start a test I get the following error:
In the Run Configurations, IntelliJ selected #angular/cli as default Jest package, which is wrong.
The correct Jest package should be jest.
After I select the correct package, Jest works and runs the selected test.
I have to do this, everytime I want to run a test.
This is not a local problem, my coworkers have the same problem in this project.

Try editing Jest run configuration template: choose the desired Jest package there, save the configuration. New configurations created from gutter/right-click menus will use these settings, you won't need to care of specifying them for each configuration

Related

WebStorm/Intellij Gherkin tests configuration run

How to set up running configuration with WebStorm feature file?
When I click on green run button seems that WebStorm can't find the steps realisation.
How could I change that WebStorm understands from where should it take steps?
When I run tests with command line it works, I have config file where I declared steps folder.
You can specify --require path/to/step/definitions as Cucumber.js arguments: field:

import { PluginConfig, ProtractorPlugin } from './plugins';

I am getting this issue when running the spec file.
before updating my dependencies it is working fine.
I was trying the update dependencies in the package.json
so I enter the this command in the terminal npm update --save.
You are receiving this error because there is a problem with your typescript compiler. You need to add #types/node and other typescript dependencies to fix this error. If you run your tests in javascript this problem should not arise. So please check your tsconfig and see if your are using ES6 libraries. Also check if the types for selenium, node, jasmine and jasminewd2 are added in your package.json.

Persisting run configuration when running tests from IntelliJ gutter

I want to run JavaScript tests from the IntelliJ gutter (the green double-arrow icons on the left side, by the line numbers).
I've set up a Run/Debug configuration for Mocha that works fine when it's used to run all my unit tests at once.
Its Node interpreter is the project's, at v8.11.4.
Its Node options are empty.
Its working directory is my/project/src.
Its environment variable is BABEL_ENV=test.
Its Mocha package is my/project/src/node_modules/mocha.
Its UI is mocha-when-then.
Its extra Mocha options are --compilers js:babel-core/register --require babel-polyfill --require ./testSetup.js --require ignore-styles.
Its test directory is my/project/src/test/, set to "All in directory".
Everything works fine when running the main, all-tests configuration. But when I run an individual test or test suite from the gutter, I get errors, because IntelliJ generates a new configuration with default settings, like blank fields for Mocha options and environment variables. I can work around this by manually copying the settings over, but having to do that for every single run is a huge waste of time.
My co-workers don't have this problem even though their configuration is identical to mine. (Identical in the IntelliJ Run/Debug Configurations menu, anyways. Obviously, something is different between our setups.)
How can I make the project settings apply or persist to tests that I run from the gutter?

How do I make IntelliJ create Mocha debug configs when running unit tests?

When I create a new Mocha test file I am presented with the expected green gutter icons (▶ and ▶▶) to run each test or the suite. When I select "Run [test name]" I expect it to create a Mocha debug configuration and run it. Instead, IntelliJ creates a NodeJS run configuration, which understandably explodes in a shower of bit-flavored WTF.
If I manually create a configuration for the whole file, everything works as expected, including individual tests afterward. I am hoping that there is a setting somewhere that I have overlooked, something like "Settings -> ... -> Default Debug Configuration".
Does anyone know how I can make IntelliJ default to Mocha when a unit test is executed?
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 current file. Do you have 'mocha' listed as a dependency/dev dependency in your package.json? How many package.json files do you have in your project?
Note that, if Mocha is not installed locally/included in package.json, you can create a Mocha run configuration with "All in directory" selected and specify a directory where your spec files are located. In this case, clicking the gutter button in a test file inside this directory will suggest to run test with Mocha.
Note also that if you have created Node.js Run configuration with "JavaScript file" set to your mocha test file, IDEA will suggest using this configuration instead of Mocha when clicking on your tests, because explicitly created run configurations associated with current file have priority over the ones auto-generated from context. Deleting the configuration should solve the issue.

How to debug Webpack-dev-server (in memory) with WebStorm?

As per WebStorm they require that we debug against a dist directory as specified in:
https://blog.jetbrains.com/webstorm/2015/09/debugging-webpack-applications-in-webstorm/
however, as per Webpack recommended development process, we should be running webpack-dev-server, so its all in memory as in:
webpack-dev-server –inline –progress –colors –display-error-details –display-cached –hot –port=3000
so there is no dist directory, which contridicts examples posted #: https://blog.jetbrains.com/webstorm/2015/09/debugging-webpack-applications-in-webstorm/
Is there a way to have webpack-dev-server use dist dir so WebStorm can be mapped to it so we can use source maps for live debug?
FYI this is the project I am using to test:
https://github.com/ocombe/ng2-webpack
tx
Sean
Currently WebStorm needs the created Bundle + SourceMap from WebPack to analyze it and find the actual Breakpoint.
So in short, you can't debug WebPack applications just with the WebPack DevServer. However you can run the normal WebPack build with file watching in parallel to it: `
As you know, you will have to create a distribution/production bundle with source maps and then use that for debugging in WebStorm. Personally, I run tests with Karma while I have the webpack-dev-server running. Karma tests can be run with the debugger and that usually satisfies any of my debugging needs, while the webpack-dev-server provides my "manual test" to see how I'm doing.
I guess what I'm saying for your case... you can have the dev server running while, at the same time, having some kind of automated build with source maps running at the exact same time which you can run and use the debugger on. This can be intensive though so it depends on your memory and processing power.
I ended up using live-server https://github.com/tapio/live-server and followed this tutorial, worked... https://blog.jetbrains.com/webstorm/2015/09/debugging-webpack-applications-in-webstorm/ (just can't use the built in server in webpack, but that's ok)
I would add that you can put the statement
debugger;
in your javascript/typescript files even in framework files of angular or vue2 like *.vue
So even if your path mappings to URL don't work, it will step anyway.