Skip to content

Commit 831a51d

Browse files
authored
docs: add migrate from CLI to README (#1444)
1 parent 435b438 commit 831a51d

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,68 @@ jobs:
14311431
| [cypress-examples](https://github.com/bahmutov/cypress-examples) | Shows separate install job from parallel test jobs |
14321432
| [cypress-gh-action-split-jobs](https://github.com/bahmutov/cypress-gh-action-split-jobs) | Shows a separate install job with the build step, and another job that runs the tests |
14331433

1434+
## Migration
1435+
1436+
### Migrating from CLI command
1437+
1438+
To migrate from Cypress [CLI run command options](https://on.cypress.io/command-line#Options) to Cypress GitHub Action parameters, check the [CLI Run Option / Action Parameter](#cli-run-option--action-parameter) table below. In most cases, the name of the action parameter is the same as the long form of the `cypress run` CLI option.
1439+
1440+
Create a [GitHub Actions workflow](https://docs.github.com/en/actions/writing-workflows/quickstart) referring to [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions). The action `cypress-io/github-action@v6` is invoked with the `uses` keyword. Cypress GitHub Action input parameters are specified under the [with](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith) keyword.
1441+
1442+
If you have previously been using a [CLI command](https://on.cypress.io/command-line#cypress-run) to run Cypress locally or in a CI environment, you will be familiar with testing commands like this:
1443+
1444+
```shell
1445+
npx cypress run --spec cypress/e2e/spec.cy.js --browser chrome
1446+
```
1447+
1448+
or you may be using a script defined in your project's `package.json` file, such as:
1449+
1450+
```json
1451+
"cy:e2e:chrome": "cypress run --spec cypress/e2e/spec.cy.js --browser chrome"
1452+
```
1453+
1454+
Here is the equivalent GitHub Actions example workflow. The action runs Cypress by passing the action parameters (`browser` and `spec`) programmatically to the [Cypress Module API](https://on.cypress.io/module-api) without using any CLI. The complete workflow also checks out the repo and installs dependencies before running Cypress.
1455+
1456+
```yml
1457+
name: CLI migration example
1458+
on: push
1459+
jobs:
1460+
cypress-run:
1461+
runs-on: ubuntu-24.04
1462+
steps:
1463+
- name: Check out repo
1464+
uses: actions/checkout@v4
1465+
- name: Cypress run # install dependencies and run Cypress E2E tests
1466+
uses: cypress-io/github-action@v6 # replaces CLI cypress run
1467+
with:
1468+
browser: chrome # replaces CLI option --browser chrome
1469+
spec: cypress/e2e/spec.cy.js # replaces CLI option --spec cypress/e2e/spec.cy.js
1470+
```
1471+
1472+
#### CLI Run Option / Action Parameter
1473+
1474+
| CLI Option `cypress run` | Action Parameter | Description |
1475+
| ------------------------------ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
1476+
| `--auto-cancel-after-failures` | [`auto-cancel-after-failures`](#auto-cancel-after-failures) | Set the failed test threshold for auto cancellation or disable auto cancellation for Cloud recording |
1477+
| `--browser`, `-b` | [`browser`](#browser) | Select browser that Cypress runs in. A filesystem path to a browser can also be used. |
1478+
| `--ci-build-id` | [`ci-build-id`](#custom-build-id) | Specify a unique identifier for a run to enable grouping or parallelization for Cloud recording |
1479+
| `--component` | [`component`](#component-testing) | Run component tests |
1480+
| `--config`, `-c` | [`config`](#config) | Specify configuration |
1481+
| `--config-file`, `-C` | [`config-file`](#config-file) | Specify configuration file |
1482+
| `--e2e` | [`component: false`](#component-testing) (default) | Run end to end tests |
1483+
| `--env`, `-e` | [`env`](#env) | Specify environment variables |
1484+
| `--group` | [`group`](#parallel) | Group recorded tests together under a single run for Cloud recording |
1485+
| `--headed` | [`headed`](#headed) | Display the browser instead of running headlessly |
1486+
| `--headless` | [`headed: false`](#headed) (default) | Hide the browser instead of running headed |
1487+
| `--parallel` | [`parallel`](#parallel) | Run recorded specs in parallel across multiple machines for Cloud recording |
1488+
| `--project`, `-P` | [`project`](#project) | Path to a specific project |
1489+
| `--quiet`, `-q` | [`quiet`](#quiet-flag) | Reduce output to `stdout` |
1490+
| `--record` | [`record`](#record-test-results-on-cypress-cloud) | Record the test run to Cypress Cloud |
1491+
| `--spec`, `-s` | [`spec`](#specs) | Specify the spec files to run |
1492+
| `--tag`, `-t` | [`tag`](#tag-recordings) | Identify a run with a tag or tags |
1493+
1494+
There is no equivalent action parameter for the CLI options `help`, `key`, `--no-exit`, `--no-runner-ui`, `port`, `reporter`, `reporter-options` or `runner-ui`. See the section [Record test results on Cypress Cloud](#record-test-results-on-cypress-cloud) for information on passing a Cypress Cloud record key to the action.
1495+
14341496
## Notes
14351497

14361498
### Installation

0 commit comments

Comments
 (0)