Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
How to run multiple tests in Cypress without closing browser?

I have a 3 spec files for testing form filling and photo uploading using cypress.

  1. spec file: Fill a form
  2. spec file: Upload a photo
  3. spec file: Check the results

Form is - https://demoqa.com/automation-practice-form

Problem is when fill a form test passes, browser is closed and 2 other test fail because I don't call open url in each test case.

If I run tests in GUI, everything is fine. Browser is not closed after first test, but when I run

npx cypress run --headed --browser chrome

from command line, problem occures.

I want to run tests from command line so browser doesn't close till all tests are finished.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I got exactly same problem and after hours of research I found a workaround that solves this. It is not a real fix but it solves your issue and mine. Here are the steps I did:

Create a 4th spec file, call it main.spec.ts, inside this file do an import for the 3 spec files you have:

import './fillform.spec.js'
import './uploadphoto.spec.js'
import './result.spec.js'

In cypress.json file, add the following entry to allow to run only the main spec file:

"testFiles": ["main.spec.js"],

Now cypress run will work exactly as cypress open and all specs will run without closing the browser in between:

npx cypress run --headed --browser chrome
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!