cypress run: keep test runner open - cypress

How can I run my Cypress tests using:
cypress run --headed
but keep the test runner open at the end of the tests, like it is using the Cypress Test Runner in interactive mode (cypress open)?
I prefer cypress run --headed over cypress open, which require user interaction to launch the tests.
(The context in running the Cypress tests in continuous integration, but with xvfb and a vnc server, so the test runner can still be used once the tests are complete).

You should be able to run:
cypress run --headed --no-exit
As of version 3.0.2, the next patch release. See the PR here

Related

Is there a way to disable Component Testing feature in cypress 10.x and above

We do not use the Component Testing feature in Cypress, which was introduced in version 10.x and above. Its an additional burden to close it every time before we land into the test runner.
You can use the --e2e flag when running Cypress via command line to launch directly to the end-to-end test suite. Assuming you're using npm, that would be:
npx cypress open --e2e
If you have a package.json file where you store your scripts, you can modify that script as well.
...
"cypress:open": "npx cypress open --e2e",
...
npm run cypress:open

Generate reports of specs run through "cypress open" app

I have reporter (mochawesome) set in cypress.json.
The thing is that this reporter is generating report .json and html files only when i run tests with "cypress run" command.
Is there a way to get reports for tests run via Cypress gui app ("cypress open") after clicking each individual test?
I'm on Ubuntu 18 and Cypress 5.5.0
Cypress wont publish results on a file, for tests run by test-runner

How to add all test run inside a test plan in test rail triggered from cypress

We are using Cypress to automate UI test cases. We have recently integrated the cypress framework with test rail. It is able to create test run in test rail.
Issue:
We want all test run should go inside a test plan or any suite or any folder. Currently all test run are created independently(can be seen in screenshot below) in the test rail "Test Run and Results Tab" which pollutes the test rail dashboard.
Is there any one all test run should go inside a plan or any folder?
Solution I have tried:
1)I have tried providing test plan id in the reporter option but didn't work.
2)Have tried #architectnow/cypress-testrail-reporter as it uses Planid but seems some issue with this package. Getting error reporter not found.
Below is the cypress Test rail reporter config:
"domain":"xxxxx.testrail.io",
"username":"email",
"password":"pass",
"projectId":1,
"planId":17,
"suiteId":1,
"runName":"Cypress Automated Test Run"
Appreciate any help in this.
You can actually use this npm package https://www.npmjs.com/package/cypress-testrail-accumulative-reporter.
npm install cypress-testrail-accumulative-reporter --save-dev
It will create one single test run and also will not be closed automatically after all spec fiels will ran.

Run Jasmine tests (coupled to DOM/jquery etc) via command line for CI

We have a set of Jasmine tests that run successfully in the local web server. http-server.
We would like to run these tests from the command line during the TeamCity build process without having to start a webserver.
Opening the html file with chrome using --disable-web-security flag results in
Failed to load module script: The server responded with a
non-JavaScript MIME type of "". Strict MIME type checking is enforced
for module scripts per HTML spec.
Probably because script references with type="module" in the SpecRunner.html file
<script src="../src/js/App/app.js" type="module"></script>
Jasmine tests are coupled to DOM/jQuery so that they need to be run in a browser. The SpecRunner html page includes script references with type="module".
How can we run these tests during a TeamCity build and fail the build if there are any test failures?
Thanks.
Here's my solution. We are already using jest for react tests and jest docs say
If you are using Jasmine, or a Jasmine like API (for example Mocha),
Jest should be mostly compatible, which makes it less complicated to
migrate to.
npm install jest puppeteer jest-puppeteer http-server
jest: To run the tests using Jasmine API
puppeteer: To run tests in headless chrome browser
http-server: Local webserver to navigate to the jasmine spec runner page
jest-puppeteer: To configure starting the local server before running the tests and stopping it afterwards
Add jest-puppeteer-config.json to start the server like this
Jest Puppeteer integrates a functionality to start a server when
running your test suite. It automatically closes the server when tests
are done.
Add a jest-puppeteer test to navigate to Jasmine SpecRunner page and assert that there are no failures.
Update your jest configuration docs
Create npm script to a run jest test that in turn runs Jasmine tests in the browser.
At this point, one should be able to run browser Jasmine tests from the command line locally or on the build server.
Here is a screenshot that shows the files and test run results both locally and on TeamCity.
How can we run these tests during a TeamCity build and fail the build
if there are any test failures?
This solution enabled us to restore around hundred legacy browser-coupled Jasmine tests as part of the build with minimum effort (did not have to update the tests).
Feel free to suggest alternatives.

How to use teamcity to run parallel cypress tests

I am using teamcity-ci to run cypress tests. For now, cypress doesn't support parallel tests in teamcity. Maybe cypress parallel test support is related with the dashboard.
If I don't use the cypress dashboard. Is it possible to run cypress test in parallel in teamcity.
I run my test in by docker-compose run cypress
For other options apart from agoldis. Pls have a look at here,
Parallel Cypress tests on TeamCity
I have been working on an open-source, self-hosted "dashboard". You can run it with your test suite - it will parallelize the tests:
Start a container from this image https://hub.docker.com/r/agoldis/sorry-cypress-director
Reconfigure cypress test runner to use the URL of the service from step 1
Run cypress as usual: cypress run --parallel --record --key <anystring> --ci-build-id <uniqueBuildId>

Resources