3

I'm using cypress typescript test framework When I call "npx cypress run" it runs all my tests in headless mode with Electron as the default browser. But I want to run it in chrome or any other browser. How do I achieve this?

4 Answers 4

11

1.If you want to run tests on for eg. chrome. you can use:

npx cypress run --browser chrome

2.If you want to run your tests in headless chrome you can use:

npx cypress run --headless --browser chrome

You can get the list of browsers that cypress supports from here

Sign up to request clarification or add additional context in comments.

3 Comments

Is there a way to specify default browser via configuration file?
@MostWanted not yet as per this issue - github.com/cypress-io/cypress/issues/6646
See defaultBrowser in docs.cypress.io/app/references/configuration#Browser since 13.16.0
1

If you want to run only through a chrome browser mode without headless, then you can use the below command: npx cypress run --headed --browser chrome

Comments

0

but in a case if you want to open your chrome window use this command :

npx cypress open

Note : First you need to make sure that your headless browser was change to chrome

Comments

-1

When it comes to angular, you could also add it to your project.json run configuration:

// project.json or angular.json

"targets": {
   ...
   "e2e": {
     "executor": "@nrwl/cypress:cypress",
     "options": {
       "cypressConfig": "apps/storybook-e2e/cypress.config.ts",
       "browser": "chrome", // <<------ this line
       "devServerTarget": "my-app:storybook",
       "testingType": "e2e"
     }
   }
 },
...

1 Comment

This question isn't related to NX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.