Skip to content

Commit

Permalink
Store screenshots and video of failing tests (#1054)
Browse files Browse the repository at this point in the history
* store screenshots and video of failing tests

* with path

* make it fail to test

* retention 7 days

* remove video
  • Loading branch information
Tbaut authored May 27, 2021
1 parent 660dc3e commit 5340857
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cypress Tests with Dependency and Artifact Caching
name: Cypress tests
on: pull_request
jobs:
cypress-run:
Expand Down Expand Up @@ -37,4 +37,20 @@ jobs:
# wait for max 2 minutes for the files-ui to respond
wait-on-timeout: 120
# custom test command to run
command: yarn test:ci:files-ui
command: yarn test:ci:files-ui
# store the screenshots if the tests fail
- name: Store screenshots
uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: packages/files-ui/cypress/screenshots
retention-days: 7
# store the videos if the tests fail
- name: Store videos
uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-videos
path: packages/files-ui/cypress/videos
retention-days: 7
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ storybook-static
.DS_Store

# test artifacts
packages/files-ui/cypress/screenshots
packages/files-ui/cypress/videos
packages/files-ui/cypress/screenshots/*
packages/files-ui/cypress/videos/*
packages/files-ui/cypress/fixtures/storage
4 changes: 3 additions & 1 deletion packages/files-ui/cypress.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"video": false
}
24 changes: 24 additions & 0 deletions packages/files-ui/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,28 @@ export default (on: any) => {
return null
}
})

on("before:browser:launch", (browser: Cypress.Browser, launchOptions: Cypress.BrowserLaunchOptions) => {
if (browser.name === "chrome" && browser.isHeadless) {
// fullPage screenshot size is 1280x720 on non-retina screens
launchOptions.args.push("--window-size=1280,720")

// force screen to be non-retina (1280x720 size)
launchOptions.args.push("--force-device-scale-factor=1")
}

if (browser.name === "electron" && browser.isHeadless) {
// fullPage screenshot size is 12807200
launchOptions.preferences.width = 1280
launchOptions.preferences.height = 720
}

if (browser.name === "firefox" && browser.isHeadless) {
// menubars take up height on the screen
launchOptions.args.push("--width=1280")
launchOptions.args.push("--height=720")
}

return launchOptions
})
}

0 comments on commit 5340857

Please sign in to comment.