intellij mocha plugin doesn't always use mocha - debugging

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.

Related

Gradle Cucumber test generates build folder on daemon instead of project directory

I have a test automation project where basically I run cucumber test via gradle task. What's weird is that the build folder is generated on .daemon folder instead of the project directory. E.g.
/Users/my_user/.gradle/daemon/5.6
Whereas it should be on:
/Users/my_user/my_project/build
Weirdly enough this seems to only happen on my local. Is there anything I might have missed on setting up the gradle?

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

How to Build a maven project using script file?

I have created a maven project in STS.I completed the development and testing code for my project.If now I want to run or build this project, then I have to do the following
Right click on the project-->Run as-->Run on Server (or)
Right click on the project-->Run as-->Maven Build
If I want to run the test code then
Right click on the class file-->Run as-->Run JUnit
But I want to create a text file I mean script file to run all these commands when I run this script file from the cmd prompt. I have found out on a web site that I should create a PowerShell file, So I don't cognize how to compose a script file like this, is there any example file for it ?
Please, anybody can help me
You can just run mvn clean install on your project root folder (i.e. where your pom.xml file is) in cmd prompt. This command will trigger your project default build lifecycle covering a number of build phases including:
validate
compile
test
package
integration-test
integration
verify
install
During these build phases, Maven will validate and compile your project, run tests (if any) against your codes, package the resultant binaries into say, a JAR file, run integration tests (if any) against your JAR, verify it, and then install the verified package to your local .m2 repository.
If you really want a script, then just add mvn clean install to your batch file.

how can I run maven test case

I have create a small web project using maven.so I want to add test classes and directory to that project.I'm using eclipse as IDE my source folder is "src/main/java" I added test source folder "src/test/java" and added one test class with one test selenium casetry to compile and run it using "mvn test" command,But console only shows "run 0 failure 0 error 0 skip 0",Can any one explain me how to run my testcases properly,is there any configurations to do ?
thnxx
mvn test runs unit tests without additional configuration, but for selenium you need to refer to selenium maven plugin.
If your tests are not in the default location src/test/java, you can specify the alternate location as follows:
<testSourceDirectory>${basedir}/my/alternate/location</testSourceDirectory>

Resources