Skip to content

Commit bb1037f

Browse files
committed
cypress: save screenshots on local headless runs
1 parent d7530e2 commit bb1037f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/cypress.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ const argv = require('yargs')
3030
})
3131
.demandOption('mode').argv;
3232

33+
const isLocalRun = !process.env.DEPLOYURL;
34+
35+
/** @type {Cypress.ConfigOptions} */
3336
const baseConfig = {
34-
baseUrl: process.env.DEPLOYURL
35-
? `${process.env.DEPLOYURL}/${argv.package}/storybook`
36-
: `http://localhost:${argv.port}`,
37+
baseUrl: isLocalRun ? `http://localhost:${argv.port}` : `${process.env.DEPLOYURL}/${argv.package}/storybook`,
3738
fixturesFolder: path.join(__dirname, 'cypress/fixtures'),
3839
integrationFolder: '.',
3940
pluginsFile: path.join(__dirname, 'cypress/plugins/index.js'),
4041
retries: {
4142
runMode: 2,
4243
openMode: 0,
4344
},
44-
screenshotOnRunFailure: false,
45+
// Screenshots go under <pkg>/cypress/screenshots and can be useful to look at after failures in
46+
// local headless runs (especially if the failure is specific to headless runs)
47+
screenshotOnRunFailure: isLocalRun && argv.mode === 'run',
4548
// due to https://github.com/cypress-io/cypress/issues/8599 this must point to a path within the package,
4649
// not a relative path into scripts
4750
supportFile: 'e2e/support.js',

0 commit comments

Comments
 (0)