You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-6Lines changed: 16 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -931,7 +931,19 @@ If you do not commit a lock file to the repository, you cannot use the action to
931
931
932
932
### Command prefix
933
933
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.
935
947
936
948
```yml
937
949
name: Visual
@@ -945,14 +957,12 @@ jobs:
945
957
- name: Cypress run
946
958
uses: cypress-io/github-action@v6
947
959
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
953
960
command-prefix: 'percy exec -- npx'
961
+
browser: chrome
954
962
```
955
963
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
+
956
966
### Custom test command
957
967
958
968
You can overwrite the Cypress run command with your own command.
0 commit comments