Cypress run some of tests in parallel - cypress

I have done lot of research of running some tests in parallel and some in series. Still, not have any great options for doing that. We'll have 4 virtual machines to done this. All tose vm's has own docker for application with own database as well. I have few tests which need to be run at the same machine.
I'll thinking can there be given some tags or something which can be configured so that spesified tags will run on VM 1 example?

Found solution by plugin named Cypress grep, link is below. With it you can write tags to tests like this:
it('works', { tags: '#smoke' }, () => ...)
run all tests tagged #smoke
$ npx cypress run --env grepTags=#smoke
run all tests except tagged #smoke
$ npx cypress run --env grepTags=-#smoke
Install instructions and usage: https://www.npmjs.com/package/#cypress/grep
Work the way as the Robot Framework tags.

Related

Mocha: run tests in parallel and serial mode

I use mocha for running tests and mocha-teamcity-reporter as a reporter for teamcity.
I have test files that can be run in parallel. And also I have some test files that should be run one by one - in serial mode.
As I understood mocha documentation, mocha can run test files only in parallel or in serial mode. So I tried to do the following: run two mocha runs with & command in one yarn script, like this:
mocha --reporter mocha-teamcity-reporter --timeout 90000 -r ts-node/register/transpile-only src/Tests/.ts --parallel --jobs 4 & mocha --reporter mocha-teamcity-reporter --timeout 90000 -r ts-node/register/transpile-only src/Tests/seq.ts
But using this approach for some reason reporter does not work properly and TeamCity does not detect all tests that were run. Is there any way to run tests like I want with mocha and mocha-teamcity-reporter?
Okay, seems that this is the only way to do it. Mentioned issue with tests detecting was resolved in one of the recent mocha updates.

Programmatically run cypress tests on docker

I am currently running cypress tests using:
await cypress.run({config inserted here})
Wondering if there is a way to spin up one of cypress's docker containers and then point the cypress tests there using the statement above. The suggestions online are to run the tests using command line, but I'm hoping to still be able to use cypress.run() and perhaps pass in an option that tells cypress to point the tests to a container?
Cypress docker containers will invoke cypress run by default. To change that, you'll need to override the container entrypoint to invoke node instead of cypress, and then pass your script file that's invoking cypress via the module api (cypress.run()) as the container command. You could do this via the command line, but it's a bit long because of all the options you'll need to pass:
# Assumes you're running this from the Cypress project directory on the host machine
$ docker run -it --rm -v $PWD:/tests -w /tests --entrypoint "/usr/local/bin/node" cypress/included:3.2.0 "myScript.js"
Warning: you're mounting in your npm dependencies with this method, which might cause problems if any of them were compiled on a different os like Windows.

Is there difference `yarn dev` and `yarn run dev`?

To run the local server for development I normally use yarn run dev.
But it seems yarn dev provides same function. Is this command just a short alias for yarn run dev?
I couldn't find info for yarn dev in documents.
You can leave out run from this command.
Basically, not only dev command, you can directly use any scripts by name without keyword run.
So, yarn dev and yarn run dev both do the same.
From the docs:
https://classic.yarnpkg.com/en/docs/cli/run/
It’s also possible to leave out the run in this command, each script can be executed with its name
And a similar example is given for yarn 2
https://yarnpkg.com/cli/run
Same thing, but without the "run" keyword :

Disable Logging test results at Cypress

I run my tests in the docker container and I would not want to see the logs about the results of the tests (since I run several instances of cypress and logs are mixed). Is there any way to turn off logging?
I have read documentation but i haven't found anything.
As per this github issue: https://github.com/cypress-io/cypress/issues/2071.
That issue was resolved at the 4.9.0 release of Cypress.
You can now run your Cypress tests with the --quiet flag. e g.:
cypress run --quiet

Nightwatch.js execute scenarios with specific tags

I'm trying run some specific scenarios using tags but I'm unable to finsh some documentation regarding that. What I want to do is run all scenarios that are marked with a specific tag. Look at the example provided on the github but it doesn't say much. What I want to do is:
#onlyone
Scenario: a random feature
Given: something
When: I do something
Then only this test should be ran
So what I want to do is run the following command nightwatch --tag #onlyone only the scenarios with that tag should be ran.
Found the appropiate documentation, Nightwatch Documentation it was an error on my part.
For me, it has been enough to run it from the command line without previous configuration.
Try this:
npm run test -- --tags #my-tag
or
npm run test:run -- --tags #my-tag
Hope this will work for you!

Resources