Skip to content

Commit 7889d8d

Browse files
authored
docs: rework command-prefix readme section (#1451)
1 parent 6d4f8f5 commit 7889d8d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,19 @@ If you do not commit a lock file to the repository, you cannot use the action to
931931

932932
### Command prefix
933933

934-
You can prefix the default test command using the `command-prefix` option. This is useful for example when running [Percy](https://docs.percy.io/docs/cypress), which requires the test command to be wrapped with `percy exec --`.
934+
You can prefix a test command using the `command-prefix` parameter. This is useful, for example, when running [BrowserStack Percy](https://www.browserstack.com/docs/percy/integrate/cypress), which requires the test command to be prefixed with `percy exec --`. When this parameter is used, the action constructs and executes a CLI command using [npx](https://docs.npmjs.com/cli/v11/commands/npx) in the following form:
935+
936+
```shell
937+
npx <command-prefix> cypress run <cli run options>
938+
```
939+
940+
where the `<command-prefix>` is the literal string value from the `command-prefix` parameter and `<cli run options>` are put together from action parameters such as the value of the `browser` parameter. The complete constructed command is shown in the logs. For the example below, this is shown as:
941+
942+
```text
943+
Cypress test command: npx percy exec -- npx cypress run --browser chrome
944+
```
945+
946+
Since `command-prefix` is run using `npx`, it is compatible with [npm](https://docs.npmjs.com/cli/v11/) and [Yarn Classic](https://classic.yarnpkg.com/). It may also be used with [pnpm](https://pnpm.io/settings#nodelinker) and [Yarn Modern](https://yarnpkg.com/configuration/yarnrc#nodeLinker) when they are configured for `nodeLinker` compatibility with the `node_modules` directory structure of npm. An alternative to using `command-prefix` is to pass a complete [command](#custom-test-command) parameter instead, including the exact command to be passed to the CLI.
935947

936948
```yml
937949
name: Visual
@@ -945,14 +957,12 @@ jobs:
945957
- name: Cypress run
946958
uses: cypress-io/github-action@v6
947959
with:
948-
start: npm start
949-
# quote the url to be safe against YML parsing surprises
950-
wait-on: 'http://localhost:8080'
951-
# the entire command will automatically be prefixed with "npm"
952-
# and we need the second "npm" to execute "cypress run ..." command line
953960
command-prefix: 'percy exec -- npx'
961+
browser: chrome
954962
```
955963

964+
If `command-prefix` is used, then no [job summary](#job-summary-title) is produced, since it runs Cypress with a CLI [cypress run](https://on.cypress.io/app/references/command-line#cypress-run) command instead of using the [Cypress Module API](https://docs.cypress.io/app/references/module-api). The `command` parameter overrides the `command-prefix` parameter, preventing these two parameters from being used together.
965+
956966
### Custom test command
957967

958968
You can overwrite the Cypress run command with your own command.

0 commit comments

Comments
 (0)