WebStorm Run icon missing in the gutter - debugging

I was looking something like this:
Here is my file structures

The logic used for determining what test runner is available for a given test file is based on dependencies declarations in package.json. Declaring "mocha" as a dependency in <project root>/package.json should enable mocha runner in <project root>/**/* files.
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, right-click on a test file inside this directory will suggest to run with Mocha.

The problem is caused by missing mocha in my npm dependencies. Maybe there is a way to tell Webstorm to look for the globally installed mocha.

Related

No spec files found when running Cypress using scripts in package.json

I am trying to use script aliases in the package.json file.
In order for something like this to open the test runner,
"cy:open:prod": "cypress open --env ENV=production",
I run the command npm run cy:open:prod in the command line in the same folder that package.json is located.
The script runs and opens the test runner, however no spec files are found.
In all the examples I have found it describes this approach. Is there something I am missing in configuation to point it to where my spec files are?
Thanks in advance.
There is nothing basically wrong with the scripts in package.json, they look normal and would not cause the problem you mention.
I suggest you check the specPattern setting in configuration, it should match the naming convention you have chosen to use for your specs.
See e2e settings for more details.
Of you still have trouble with it, start a new project and let Cypress set the configuration for you, it will automatically match up the specPattern to the default value.

How to run tests outside of integration folder in Cypress

I have project B linked to project A with npm link and am trying to run tests from B in A. Project A builds the entire front end and could use other modules than just B and so I want to be able have the test runner use A and its tests but also use tests from the linked project (assuming the linked projects all use similar Cypress directory structures). I first tried this by setting the testFiles attribute in the config to an array like [/path/to/ProjectATestingRoot/integration/**/*.*", "/path/to/ProjectBTestingRoot/integration/**/*.*"]
and running Cypress with integrationFolder to be from project A. While I'm able to see all my tests when I open Cypress, only project A's tests can be run. When I run project B's they get stuck when the browser loads the test and displays the "Your tests are loading..." screen for eternity.
Is there any way that I could run tests from outside the set integration folder? I thought I could write a little plugin to copy the testing files over but that seems more laborious than needed.
Using spec should solve the problem
npx cypress run --spec [abloluteFolderPath}
"testFiles": "**/*.{feature,spec.tsx}",
"integrationFolder": ".",
"ignoreTestFiles": "**/node_modules/**/*{feature,spec.js}"
Add this to your cypress.json. It adds all the files with .spec.tsx ignoring the ones inside the node_module.
https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/unit-testing__application-code
There are 2 options
1 You can specify integrationFolder in the cypress.json
{
//....
"integrationFolder": "cypress/tests"
// or
// "integrationFolder": "tests"
}
More information https://docs.cypress.io/guides/references/configuration#Folders-Files
2 You can specify integration folder for each test run
npx cypress --config integrationFolder=cypress/tests
npx cypress --config integrationFolder=tests
More information https://github.com/cypress-io/cypress/issues/2256#issuecomment-544408366

Node.js: re-run cucumberjs tests automatically on each source file change

What is the simplest way to tell cucumberjs to watch for source project files changes so that it can re-runs its tests?
You could add a gulp task. Here is more information on how gulp works https://gulpjs.com/docs/en/api/concepts

intellij mocha plugin doesn't always use mocha

Normally from the IntelliJ's 'projects' pane, I can right click on a test file and choose 'debug' or 'run' and the Mocha Plugin intercepts it and automatically creates run/debug configurations for the file. This causes IntelliJ to use the following command: (note presence of mocha)
/usr/local/bin/node --debug-brk=57425 /projects/my_project/node_modules/mocha/bin/_mocha --timeout 3600000 --ui bdd --reporter "/Users/shared/Library/Application Support/IntelliJIdea2016.1/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js" /projects/my_project/tests/src/scripts/my-other-test.js
Other times (for nearly identical files in the same folder) it doesn't: (note mocha is absent)
/usr/local/bin/node --debug-brk=57068 my-test.js
The only way I've been able to run the test file is to manually create a Run Configuration specific to that file.
What do I have to do to encourage the Mocha Plugin to automatically create a run/debug configuration?
You need to make sure that mocha package is installed locally in your project. Mocha plugin checks that and creates mocha-command instead of node-command.

Configure Mocha Test Runner in Bamboo

I've configured and am executing mocha tests in WebStorm, so I know the module is working properly. But I can't seem to make it run from a Bamboo task. The task runs with Success but there are 0 tests executed.
This is my configuration atm:
app/ is my working dir. Tried also with app/node_modules/mocha/bin/ and other possibilities. I am not sure which exactly is the Mocha executable of all the mocha named files in the module...
Or maybe the problem lies in the tests dir? I've got test files, respectively in app/test/unit/models/ and app/test/unit/services/. But in WebStorm I configured it with the general test dir - just /app/test. Configuring the Mocha task in Bamboo with the specific test folders did not yield result...
I believe the problem comes from wrong directory configurations in the task, but I've tried writing whatever paths already and I've got no idea what's missing or wrong...
I noticed from your screenshot that the "Parse test results produced by this task" box isn't checked. This is what tells Bamboo to parse the output of the tests that you run.

Resources