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
Related
I have found if I only add karate core dependency and run my tests, they run fine and report is generated.
So what is importance of making a test runner class? I can run my karate tests without it as well. Kindly explain!
With Karate runner class , you can use #KarateOptions to include or exclude feature files that you want to run eg #KarateOptions(features = "classpath:FeatureFiles/test.feature" , tags = "~#Smoke") will run all feature files other than the one having #Smoke tag .
How to pass parameter to run Karate tests from cmd/terminal as maven project
If we want to run only 'Smoke' tests then code can be written as :
Open cmd/terminal
cd 'karate project path'
mvn test -Dkarate.options="--tags #Smoke classpath:FeatureFiles"
There are multiple projects inside our repo.
Eg.
MainProject/
SubProject_1/
SubProject_2/
After I installed cypress, "Cypress" folders were created for each project.
MainProject/
Cypress
SubProject_1/
Cypress
SubProject_2/
Cypress
Now in package.json file I've got;
Script
{
"cypress:open": "cypress open",
}
When I run npm run cypress:open, it opens up UI for root directory. Which is;
MainProject/
Cypress
If I want to open cypress for different folder as below, how should I try modify the script ?
SubProject_1/
Cypress
Please note that, I've got cypress v10.
When I run Cypress open --project ./SubProject_1/Cypress, it created a folder /SubProject_1/Cypress.
Thanks
I think you want to specify the config file for the particular project,
See Specifying an Alternative Config File
"open:sub1": "cypress open --config-file SubProject_1/cypress.config.js"
Each project config would specify the folders relative to that project.
I'm using Javascript with Cypress framework to automate tests.
How do I mark tests as tier1 , tier 2 etc. so that I could run only tests marked tier1 or tier2 ?
You can group them by folders, and then use the ignoreTestFiles and testFiles config params to ignore or use them, according to your needs.
You will have to use the route that matches all the tests inside the folder.
For example, you have three folders inside the integration folder called Tier1, Tier2 and Tier3. To indicate that Cypress should ignore tests inside Tier1 and only use Tier2 and Tier3 you have to add to your config:
ignoreTestFiles: '**/Tier1/*.js'
Or if you prefer:
testFiles: ['**/Tier2/*.js', '**/Tier3/*.js']
To know more about config params take a look to the Cypress docs: https://docs.cypress.io/guides/references/configuration#Folders-Files
Set up different subfolders in your integration folder in Cypress, called "tier1", tier2", tier3"
npx cypress run will still run all subfolders
"npx cypress run --spec "cypress/integration/{subfolder}/*-spec.js" will run all tests in a specific subfolder
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.
I have inherited a Go project that consists of a lot of common files, a library of sorts, two executables, and theoretically a test suite. The test suite is being written after the fact. But I dislike the only way I've found of setting up is rather unpalatable
I'm using Ginkgo, and this is my starting directory structure
component1/component1.go
component2/component2.go
cmd1/cmd1.go
cmd2/cmd2.go
project_suite_test.go
component1_test.go
Each cmd?.go file will be compiled into a separate executable.
What I would like is a multi-file test suite, usually one file per component. Where do I put the files so that go test will find and run all of them, without leaving them here in the root of the project?
ginkgo init and ginkgo bootstrap will set up your tests. ginkgo -r will run all your tests recursively.
Reason:
Ginkgo command will only work if you have actually bootstrap your project via ginkgo.
Options:
To use that you have to go to your test dir in terminal and run
ginkgo init : To Initialise project:
ginkgo bootstrap : This will generate new file with test suite config
ginkgo or ginkgo test : this will now be able to run tests based on your new generated file because that's what it is trying to search.
Alternatively:
If you like to keep your tests in a sub-folder, say test, then running
go test ./...
will attempt to run tests in every folder, even those that do not contain any test, thus having a ? in the subsequent report for non-test folders.
Running
go test ./.../test
instead will target only your test folders, thus having a clean report focused on your tests folders only.
you can alternatively use 'go run $(ls *.go)' to run all the files in a given folder.
Notice you have regular expression within () braces.
In-case you want to run test in different path update path as per your desired dir in the regular expression
You can use go test ./... in the root and it will go into child folders and execute the tests:
component1/component1.go
component1/component1_test.go
component2/component2.go
component2/component2_test.go
cmd1/cmd1.go
cmd1/cmd1_test.go
cmd2/cmd2.go
cmd2/cmd2_test.go