<commit_before>---
title: Command Line
---

<Alert type="info">

## <Icon name="graduation-cap"></Icon> What you'll learn

- How to run Cypress from the command line
- How to specify which spec files to run
- How to launch other browsers
- How to record your tests to the Dashboard

</Alert>

## Installation

This guide assumes you've already read our
[Installing Cypress](/guides/getting-started/installing-cypress) guide and
installed Cypress as an `npm` module. After installing you'll be able to execute
all of the commands in this document from your **project root**.

## How to run commands

<Alert type="info">

You can alternatively require and run Cypress as a node module using our
[Module API](/guides/guides/module-api).

</Alert>

For brevity we've omitted the full path to the cypress executable in each
command's documentation.

To run a command, you'll need to prefix each command in order to properly locate
the cypress executable.

```shell
$(npm bin)/cypress run
```

...or...

```shell
./node_modules/.bin/cypress run
```

...or... (requires npm@5.2.0 or greater)

```shell
npx cypress run
```

...or by using Yarn...

```shell
yarn open
```

You may find it easier to add the cypress command to the `scripts` object in
your `package.json` file and call it from an
[`npm run` script](https://docs.npmjs.com/cli/run-script.html).

When calling a command using `npm run`, you need to pass the command's arguments
using the `--` string. For example, if you have the following command defined in
your `package.json`

```json
{
  "scripts": {
    "cy:run": "cypress run"
  }
}
```

...and want to run tests from a single spec file and record the results on the
Dashboard, the command should be:

```shell
npm run cy:run -- --record --spec "cypress/integration/my-spec.js"
```

If you are using the [npx](https://github.com/zkat/npx) tool, you can invoke the
locally installed Cypress tool directly:

```shell
npx cypress run --record --spec "cypress/integration/my-spec.js"
```

<Alert type="info">

Read how we typically organize and execute npm scripts in the blog post
[How I Organize my npm Scripts](https://glebbahmutov.com/blog/organize-npm-scripts/).

</Alert>

## Commands

### `cypress run`

Runs Cypress tests to completion. By default, `cypress run` will run all tests
headlessly.

```shell
cypress run [options]
```

#### Options

| Option                     | Description                                                                                                                                                                                |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--browser`, `-b`          | [Run Cypress in the browser with the given name. If a filesystem path is supplied, Cypress will attempt to use the browser at that path.](#cypress-run-browser-lt-browser-name-or-path-gt) |
| `--ci-build-id`            | [Specify a unique identifier for a run to enable grouping or parallelization.](#cypress-run-ci-build-id-lt-id-gt)                                                                          |
| `--config`, `-c`           | [Specify configuration](#cypress-run-config-lt-config-gt)                                                                                                                                  |
| `--config-file`, `-C`      | [Specify configuration file](#cypress-run-config-file-lt-config-file-gt)                                                                                                                   |
| `--env`, `-e`              | [Specify environment variables](#cypress-run-env-lt-env-gt)                                                                                                                                |
| `--group`                  | [Group recorded tests together under a single run](#cypress-run-group-lt-name-gt)                                                                                                          |
| `--headed`                 | [Displays the browser instead of running headlessly](#cypress-run-headed)                                                                                                                  |
| `--headless`               | [Hide the browser instead of running headed (default during `cypress run`)](#cypress-run-headless)                                                                                         |
| `--help`, `-h`             | Output usage information                                                                                                                                                                   |
| `--key`, `-k`              | [Specify your secret record key](#cypress-run-record-key-lt-record-key-gt)                                                                                                                 |
| `--no-exit`                | [Keep Cypress Test Runner open after tests in a spec file run](#cypress-run-no-exit)                                                                                                       |
| `--parallel`               | [Run recorded specs in parallel across multiple machines](#cypress-run-parallel)                                                                                                           |
| `--port`,`-p`              | [Override default port](#cypress-run-port-lt-port-gt)                                                                                                                                      |
| `--project`, `-P`          | [Path to a specific project](#cypress-run-project-lt-project-path-gt)                                                                                                                      |
| `--quiet`, `-q`            | If passed, Cypress output will not be printed to `stdout`. Only output from the configured [Mocha reporter](/guides/tooling/reporters) will print.                                         |
| `--record`                 | [Whether to record the test run](#cypress-run-record-key-lt-record-key-gt)                                                                                                                 |
| `--reporter`, `-r`         | [Specify a Mocha reporter](#cypress-run-reporter-lt-reporter-gt)                                                                                                                           |
| `--reporter-options`, `-o` | [Specify Mocha reporter options](#cypress-run-reporter-lt-reporter-gt)                                                                                                                     |
| `--spec`, `-s`             | [Specify the spec files to run](#cypress-run-spec-lt-spec-gt)                                                                                                                              |
| `--tag`, `-t`              | [Identify a run with a tag or tags](#cypress-run-spec-lt-spec-gt)                                                                                                                          |

#### `cypress run --browser <browser-name-or-path>`<commit_msg>Fix `Identify a run with a tag or tags` link<commit_after>---
title: Command Line
---

<Alert type="info">

## <Icon name="graduation-cap"></Icon> What you'll learn

- How to run Cypress from the command line
- How to specify which spec files to run
- How to launch other browsers
- How to record your tests to the Dashboard

</Alert>

## Installation

This guide assumes you've already read our
[Installing Cypress](/guides/getting-started/installing-cypress) guide and
installed Cypress as an `npm` module. After installing you'll be able to execute
all of the commands in this document from your **project root**.

## How to run commands

<Alert type="info">

You can alternatively require and run Cypress as a node module using our
[Module API](/guides/guides/module-api).

</Alert>

For brevity we've omitted the full path to the cypress executable in each
command's documentation.

To run a command, you'll need to prefix each command in order to properly locate
the cypress executable.

```shell
$(npm bin)/cypress run
```

...or...

```shell
./node_modules/.bin/cypress run
```

...or... (requires npm@5.2.0 or greater)

```shell
npx cypress run
```

...or by using Yarn...

```shell
yarn open
```

You may find it easier to add the cypress command to the `scripts` object in
your `package.json` file and call it from an
[`npm run` script](https://docs.npmjs.com/cli/run-script.html).

When calling a command using `npm run`, you need to pass the command's arguments
using the `--` string. For example, if you have the following command defined in
your `package.json`

```json
{
  "scripts": {
    "cy:run": "cypress run"
  }
}
```

...and want to run tests from a single spec file and record the results on the
Dashboard, the command should be:

```shell
npm run cy:run -- --record --spec "cypress/integration/my-spec.js"
```

If you are using the [npx](https://github.com/zkat/npx) tool, you can invoke the
locally installed Cypress tool directly:

```shell
npx cypress run --record --spec "cypress/integration/my-spec.js"
```

<Alert type="info">

Read how we typically organize and execute npm scripts in the blog post
[How I Organize my npm Scripts](https://glebbahmutov.com/blog/organize-npm-scripts/).

</Alert>

## Commands

### `cypress run`

Runs Cypress tests to completion. By default, `cypress run` will run all tests
headlessly.

```shell
cypress run [options]
```

#### Options

| Option                     | Description                                                                                                                                                                                |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--browser`, `-b`          | [Run Cypress in the browser with the given name. If a filesystem path is supplied, Cypress will attempt to use the browser at that path.](#cypress-run-browser-lt-browser-name-or-path-gt) |
| `--ci-build-id`            | [Specify a unique identifier for a run to enable grouping or parallelization.](#cypress-run-ci-build-id-lt-id-gt)                                                                          |
| `--config`, `-c`           | [Specify configuration](#cypress-run-config-lt-config-gt)                                                                                                                                  |
| `--config-file`, `-C`      | [Specify configuration file](#cypress-run-config-file-lt-config-file-gt)                                                                                                                   |
| `--env`, `-e`              | [Specify environment variables](#cypress-run-env-lt-env-gt)                                                                                                                                |
| `--group`                  | [Group recorded tests together under a single run](#cypress-run-group-lt-name-gt)                                                                                                          |
| `--headed`                 | [Displays the browser instead of running headlessly](#cypress-run-headed)                                                                                                                  |
| `--headless`               | [Hide the browser instead of running headed (default during `cypress run`)](#cypress-run-headless)                                                                                         |
| `--help`, `-h`             | Output usage information                                                                                                                                                                   |
| `--key`, `-k`              | [Specify your secret record key](#cypress-run-record-key-lt-record-key-gt)                                                                                                                 |
| `--no-exit`                | [Keep Cypress Test Runner open after tests in a spec file run](#cypress-run-no-exit)                                                                                                       |
| `--parallel`               | [Run recorded specs in parallel across multiple machines](#cypress-run-parallel)                                                                                                           |
| `--port`,`-p`              | [Override default port](#cypress-run-port-lt-port-gt)                                                                                                                                      |
| `--project`, `-P`          | [Path to a specific project](#cypress-run-project-lt-project-path-gt)                                                                                                                      |
| `--quiet`, `-q`            | If passed, Cypress output will not be printed to `stdout`. Only output from the configured [Mocha reporter](/guides/tooling/reporters) will print.                                         |
| `--record`                 | [Whether to record the test run](#cypress-run-record-key-lt-record-key-gt)                                                                                                                 |
| `--reporter`, `-r`         | [Specify a Mocha reporter](#cypress-run-reporter-lt-reporter-gt)                                                                                                                           |
| `--reporter-options`, `-o` | [Specify Mocha reporter options](#cypress-run-reporter-lt-reporter-gt)                                                                                                                     |
| `--spec`, `-s`             | [Specify the spec files to run](#cypress-run-spec-lt-spec-gt)                                                                                                                              |
| `--tag`, `-t`              | [Identify a run with a tag or tags](#cypress-run-tag-lt-tag-gt)                                                                                                                          |

#### `cypress run --browser <browser-name-or-path>`
{'fraction_non_alphanumeric': 0.1260048093438681, 'fraction_numerical': 0.00041222947440742015, 'mean_word_length': 0.9841875681570338, 'pattern_counts': {'":': 4, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 192, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7375086', 'n_tokens_mistral': 3101, 'n_tokens_neox': 2940, 'n_words': 1014}