Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/example-expose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: example-expose
# In the example jobs, the action is called with
# uses: ./
# which runs the action code from the current branch.
# If you copy this workflow to another repo, replace the line with
# uses: cypress-io/github-action@v7
on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:

jobs:
with-expose:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Cypress run with expose
uses: ./
with:
working-directory: examples/expose
expose: host=http://api.dev.local,apiPort=4222
spec: cypress/e2e/spec.cy.js
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ See [Releases](https://github.com/cypress-io/github-action/releases) for full de

| Version | Changes |
| ------- | ------------------------------------------------------------------------------------------------------------ |
| v7.3.0 | Add parameter `expose` for [`Cypress.expose()`](https://docs.cypress.io/api/cypress-api/expose) support |
| v7.2.0 | Examples remove Node.js 20. End of support for Node.js 20. |
| v7.1.0 | Add parameter `package-manager-cache` |
| v7.0.0 | Action runs under Node.js 24 instead of Node.js 20 |
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following examples demonstrate the actions' functions.
- using [headed mode](#headed)
- Using [Docker image](#docker-image)
- Specify [environment variables](#env)
- Specify [expose variables](#expose)
- Run only some [spec files](#specs)
- Test [project in subfolder](#project)
- [Record results](#record-test-results-on-cypress-cloud) on Cypress Cloud
Expand Down Expand Up @@ -358,6 +359,30 @@ For more examples, see the workflows below, using environment variables for [rec

[![Env example](https://github.com/cypress-io/github-action/actions/workflows/example-env.yml/badge.svg)](.github/workflows/example-env.yml)

### Expose

Specify the expose argument with `expose` parameter. Expose variables are for non-sensitive, public config values that are synchronous and exposed to the browser (requires Cypress 15.10.0 or later).

```yml
name: Cypress tests
on: push
jobs:
cypress-run:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Cypress run with expose
uses: cypress-io/github-action@v7
with:
expose: host=api.dev.local,port=4222
```

For more information, see [Cypress.expose()](https://docs.cypress.io/api/cypress-api/expose) in the Cypress documentation.

[![Expose example](https://github.com/cypress-io/github-action/actions/workflows/example-expose.yml/badge.svg)](.github/workflows/example-expose.yml)

### Specs

Specify the [spec files to run](https://docs.cypress.io/guides/guides/command-line.html#cypress-run-spec-lt-spec-gt) with `spec` parameter
Expand Down Expand Up @@ -1619,6 +1644,7 @@ jobs:
| `--config-file`, `-C` | [`config-file`](#config-file) | Specify configuration file |
| `--e2e` | [`component: false`](#component-testing) (default) | Run end to end tests |
| `--env`, `-e` | [`env`](#env) | Specify environment variables |
| `--expose`, `-x` | [`expose`](#expose) | Specify expose variables for non-sensitive, public config values |
| `--group` | [`group`](#parallel) | Group recorded tests together under a single run for Cloud recording |
| `--headed` | [`headed`](#headed) | Display the browser instead of running headlessly |
| `--headless` | [`headed: false`](#headed) (default) | Hide the browser instead of running headed |
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ inputs:
env:
description: 'Sets Cypress environment variables'
required: false
expose:
description: 'Sets Cypress expose variables for non-sensitive, public config values (requires Cypress 15.10.0 or later)'
required: false
group:
description: 'Group setting for recording tests'
required: false
Expand Down
15 changes: 14 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102320,6 +102320,12 @@ const runTestsUsingCommandLine = async () => {
cmd.push(envInput)
}

const exposeInput = core.getInput('expose')
if (exposeInput) {
cmd.push('--expose')
cmd.push(exposeInput)
}

const quiet = getInputBool('quiet')
if (quiet) {
cmd.push('--quiet')
Expand Down Expand Up @@ -102360,6 +102366,7 @@ const commandIgnoredStringInputs = [
'config',
'config-file',
'env',
'expose',
'group',
'project',
'spec',
Expand All @@ -102383,7 +102390,9 @@ const validateCustomCommand = () => {
})
if (ignoredInputParameters.length > 0) {
core.warning(
`command parameter is used and the following other parameters are ignored: ${ignoredInputParameters.sort().join(', ')}.`
`command parameter is used and the following other parameters are ignored: ${ignoredInputParameters
.sort()
.join(', ')}.`
)
}
}
Expand Down Expand Up @@ -102479,6 +102488,10 @@ const runTests = async () => {
cypressOptions.env = core.getInput('env')
}

if (core.getInput('expose')) {
cypressOptions.expose = core.getInput('expose')
}

if (cypressOptions.parallel || cypressOptions.group) {
const { branch, buildId } = await getCiBuildId()
if (branch) {
Expand Down
12 changes: 12 additions & 0 deletions examples/expose/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'cypress'

export default defineConfig({
fixturesFolder: false,
e2e: {
setupNodeEvents (on, config) {
console.log('logging from cypress.config.js')
console.log('entire config.expose', config.expose)
},
supportFile: false,
},
})
12 changes: 12 additions & 0 deletions examples/expose/cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
it('has all expected expose variables', () => {
expect(Cypress.expose('host'), 'host is an URL').to.match(
/^https?:\/\//,
)
expect(
Cypress.expose(),
'full expose includes API info',
).to.deep.include({
host: 'http://api.dev.local',
apiPort: 4222,
})
})
Loading