Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: set up included-non-root example screenshot #1273

Merged
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
17 changes: 17 additions & 0 deletions examples/included-as-non-root/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,20 @@ docker run --rm -v .:/test -w /test -u node cypress/included
```

You can expect this command to run successfully.

## GitHub Actions

In general when running Cypress Docker images in GitHub Actions it is recommended to use the GitHub Actions' `container` syntax (see [Running jobs in a container](https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container) and [.github/workflows/example-cypress-github-action.yml](../../.github/workflows/example-cypress-github-action.yml)).

If however Docker is run directly in a GitHub Actions workflow, such as:

```yaml
- run: docker run --rm -v .:/test -w /test -u node cypress/included
working-directory: examples/included-as-non-root
```

then the `docker` command will be run from GitHub's `runner` user `1001` and the Cypress Docker image `node` user `1000` will have no write access to the `/test` directory. Cypress will warn that the project root directory is read-only and that screenshots and videos cannot be captured.

To enable screenshot and video captures, redirect the folders to a writable folder, such as `/tmp`. See [cypress.config.js](./cypress.config.js) for an example.

Pending resolution of Cypress issue https://github.com/cypress-io/cypress/issues/30810, Cypress will however still produce a warning.
7 changes: 5 additions & 2 deletions examples/included-as-non-root/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const { defineConfig } = require('cypress')
const { defineConfig } = require('cypress');

module.exports = defineConfig({
downloadsFolder: '/tmp/cypress/downloads',
screenshotsFolder: '/tmp/cypress/screenshots',
videosFolder: '/tmp/cypress/videos',
fixturesFolder: false,
e2e: {
supportFile: false,
},
})
});
1 change: 1 addition & 0 deletions examples/included-as-non-root/cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ describe('test local demo page', () => {
it('heading', () => {
cy.visit('index.html')
cy.contains('h2', 'Test')
cy.screenshot()
})
})