forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.js
executable file
·74 lines (68 loc) · 1.81 KB
/
cypress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
const cypress = require('cypress');
const path = require('path');
/**
* Script that run/opens cypress, since cypress does not support easy config extension
* Can be removed in favour of native CLI once cypress supports path based config extension
* https://github.com/cypress-io/cypress/issues/5674
*/
const argv = require('yargs')
.option('mode', {
describe: 'Choose a mode to run cypress',
choices: ['run', 'open'],
})
.option('port', {
describe: 'Port number storybook is running on',
default: 3000,
type: 'number',
})
.demandOption('mode').argv;
const baseConfig = {
baseUrl: process.env.DEPLOYURL
? // Base path hard coded for converged for now, can be modified to be configurable if required to other projects
`${process.env.DEPLOYURL}/react-components/storybook`
: `http://localhost:${argv.port}`,
fixturesFolder: path.join(__dirname, 'cypress/fixtures'),
integrationFolder: '.',
pluginsFile: path.join(__dirname, 'cypress/plugins/index.js'),
retries: {
runMode: 2,
openMode: 0,
},
screenshotOnRunFailure: false,
// due to https://github.com/cypress-io/cypress/issues/8599 this must point to a path within the package,
// not a relative path into scripts
supportFile: 'e2e/support.js',
testFiles: ['**/e2e/**/*.e2e.ts'],
video: false,
};
const run = () => {
return cypress.run({
configFile: false,
config: {
...baseConfig,
},
});
};
const open = () => {
cypress.open({
configFile: false,
config: {
...baseConfig,
},
});
};
if (argv.mode === 'open') {
open();
} else {
return run()
.then(result => {
if (result.totalFailed) {
throw new Error(`${result.totalFailed} failing E2E tests`);
}
})
.catch(err => {
console.error(err);
process.exit(1);
});
}