Skip to content

Commit

Permalink
test: set up included-non-root example screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcC399 committed Jan 3, 2025
1 parent 31d5a60 commit 0dc31f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
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()
})
})

0 comments on commit 0dc31f7

Please sign in to comment.