Skip to content

Commit

Permalink
Capture video of failed E2E tests
Browse files Browse the repository at this point in the history
Update Cypress config to record video, but delete if a spec passes.

Mount the prow artifacts folder so we upload videos on failure.
  • Loading branch information
AlanGreene authored and tekton-robot committed Sep 16, 2022
1 parent 04d4de6 commit 38299cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
15 changes: 13 additions & 2 deletions packages/e2e/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,28 @@ limitations under the License.
*/

const { defineConfig } = require('cypress');
const { unlink } = require('node:fs/promises');

const isCI = process.env.CI === 'true';

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:8000',
// experimentalSessionAndOrigin: true, // default is false
experimentalStudio: true
experimentalStudio: true,
setupNodeEvents(on, _config) {
on('after:spec', (spec, results) => {
if (isCI && results && results.video && results.stats.failures === 0) {
console.log('Deleting video for passing test'); // eslint-disable-line no-console
return unlink(results.video);
}

return null;
});
}
},
screenshotOnRunFailure: !isCI,
video: !isCI,
video: true,
viewportHeight: 800, // default 660
viewportWidth: 1280 // default 1000
// waitForAnimations: true // disable to account for spinners?
Expand Down
11 changes: 9 additions & 2 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,15 @@ test_dashboard() {
fi

echo "Running browser E2E tests…"
docker run --rm --network=host dashboard-e2e || fail_test "Browser E2E tests failed"

VIDEO_PATH=$ARTIFACTS/videos
mkdir -p $VIDEO_PATH
chmod -R 777 $VIDEO_PATH
# In case of failure we'll upload videos of the failing tests
# Our Cypress config will delete videos of passing tests before exiting
docker run --rm --network=host -v $VIDEO_PATH:/home/node/cypress/videos dashboard-e2e || fail_test "Browser E2E tests failed"

# If we get here the tests passed, no need to upload artifacts
rm -rf $VIDEO_PATH
kill -9 $dashboardForwardPID

$tekton_repo_dir/scripts/installer uninstall ${@:2}
Expand Down

0 comments on commit 38299cb

Please sign in to comment.