Within my playwright.config.ts file, I have specified the following:
use: {
...
screenshot: 'only-on-failure',
}
When running tests locally and they fail, screenshots are successfully saved in /test-results. However, the issue arises when the tests fail while running in Github Actions, as no screenshots are generated. This makes it challenging for me to identify the cause of the failures, especially since the tests pass without any issues locally.
The CI-specific sections of my configuration are as follows:
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI ? 'github' : 'list',
Additionally, my action.yml file attempts to upload the /test-results folder, but it always appears to be empty since no screenshots were captured:
- uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-test-results
path: test-results/