Difference between Karma start and run Karma? - qunit

When I enter 'karma start' in the WebStorms' terminal, it opens Chrome and I can start testing, when I make some changes, it reruns the tests. But what is the difference when I type Karma start or when I click un Run Karma? Is Run Karma only for test reporters?

There are 2 console commands:
karma start
karma run
Karma start creates a karma server with the given config file and opens a browser window which connects to that server and waits for tests. You should use karma start after every change of your karma.conf.js file. The PhpStorm plugin does this automatically, by run it checks whether the config file is changed, and if so, it executes karma start before karma run.
Karma run sends your tests to the browser and runs them there. Your should use this after every change of your code or unit tests. Ofc the PhpStorm plugin does this automatically by every run.

The standard way is to run karma start and karma run as described by #inf3rno.
When running karma on CI/CD it's good to start karma, run the tests and exit. It's possible to reach using the singleRun: true option in the karma.conf.js. Check it out in the docs http://karma-runner.github.io/1.0/config/configuration-file.html.

Related

Cypress run some of tests in parallel

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.

Cypress custom reporter problem with --spec flag

When I run tests via npx cypress run everything works fine, but when I want to run one or more tests via the --spec flag, I can't find this tests in the config and the reporter logic breaks, since the config doesn't changed testFiles field, if you specify the testFiles field in cypress.json or set it via the CLI npx cypress run --config testFiles='examp.spec.js' then everything works fine.
Here our cypress-reporter https://www.npmjs.com/package/#zebrunner/javascript-agent-cypress

Run cypress test without using the GUI

Is it possible to run a Cypress test without using the GUI where you can choose the test file. Currently I open it this way:
I type in CMD: node_modules/.bin/cypress open and then the GUI pops up where I can choose my test.
Is there a command which avoids that the GUI is popping up and what is the command?
You can run with command line in headed like this:
node_modules\\.bin\\cypress run --headed
this will run the tests by default in Electron browser.
And headless:
node_modules\\.bin\\cypress run
Yes, it is cypress run. It is all described in the documentation.
To run a specific file, you need to pass --spec argument, like this:
node_modules/.bin/cypress run --spec "cypress/integration/nameOfTheTest.js"

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

Jenkins doesn't wait Grunt serve command to be completed

I'm having an issue with my Jenkins job.
I'm doing a bunch of tests on my repository and to make these tests at some point I need to serve this repo locally. So I'm doing:
grunt serve:dist &
It seems though that Jenkins execute shell does not wait the command to finish and starts to run the next commands which unfortunately makes the job fail.
To overcome this I added a sleep 100 after the above command to give time for the serve command to finish but that doesn't feel that good and clean.
Is there another cleaner way to wait for grunt serve:dist & to finish?

Resources