forked from Synthetixio/synpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synpress.js
135 lines (124 loc) · 3.82 KB
/
synpress.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env node
const program = require('commander');
const { run, open } = require('./launcher');
const { version } = require('./package.json');
if (process.env.SYNPRESS_LOCAL_TEST) {
require('dotenv').config();
} else {
require('dotenv').config({ path: require('find-config')('.env') });
}
if (process.env.SYNDEBUG) {
process.env.PWDEBUG = 1;
// process.env.DEBUG = 'cypress:*';
if (!process.env.STABLE_MODE) {
process.env.STABLE_MODE = true;
}
}
if (
!process.env.SECRET_WORDS &&
!process.env.PRIVATE_KEY &&
!process.env.SKIP_METAMASK_SETUP &&
!process.env.SKIP_METAMASK_INSTALL
) {
throw new Error(
'Please provide SECRET_WORDS or PRIVATE_KEY environment variable',
);
}
if (process.env.RPC_URL || process.env.CHAIN_ID) {
if (!process.env.RPC_URL) {
throw new Error('Please provide RPC_URL environment variable');
} else if (!process.env.CHAIN_ID) {
throw new Error('Please provide CHAIN_ID environment variable');
}
if (
!process.env.RPC_URL.startsWith('http://') && //DevSkim: ignore DS137138
!process.env.RPC_URL.startsWith('https://')
) {
throw new Error(
'RPC_URL environment variable should start with "http://" or "https://"', //DevSkim: ignore DS137138
);
}
if (process.env.BLOCK_EXPLORER) {
if (
!process.env.BLOCK_EXPLORER.startsWith('http://') && //DevSkim: ignore DS137138
!process.env.BLOCK_EXPLORER.startsWith('https://')
) {
throw new Error(
'BLOCK_EXPLORER environment variable should start with "http://" or "https://"', //DevSkim: ignore DS137138
);
}
}
}
program.version(version, '-v, --version');
program
.command('run')
.requiredOption('-b, --browser <name>', 'run on specified browser', 'chrome')
.option(
'-c, --config <config>',
'set configuration values, separate multiple values with a comma',
)
.option(
'-cf, --configFile <path>',
'specify a path to a JSON file where configuration values are set',
)
.option(
'-e, --env <env=val>',
'set environment variables, separate multiple values with comma',
)
.option('-s, --spec <path or glob>', 'run only provided spec files')
.option('-ne, --noExit', 'keep runner open after tests finish')
.option('-pr, --project <path>', 'run with specific project path')
.option('-q, --quiet', 'only test runner output in console')
.option('-r, --reporter <reporter>', 'specify mocha reporter')
.option(
'-ro, --reporterOptions <options>',
'specify mocha reporter options, separate multiple values with comma',
)
// dashboard
.option(
'-r, --record',
'[dashboard] record video of tests running after setting up your project to record',
)
.option('-k, --key <key>', '[dashboard] set record key')
.option(
'-p, --parallel',
'[dashboard] run recorded specs in parallel across multiple machines',
)
.option(
'-g, --group <name>',
'[dashboard] group recorded tests together under a single run',
)
.option('-t, --tag <name>', '[dashboard] add tags to dashboard for test run')
.description('launch tests')
.action(options => {
run({
browser: options.browser,
config: options.config,
configFile: options.configFile,
env: options.env,
spec: options.spec,
noExit: options.noExit,
project: options.project,
quiet: options.quiet,
reporter: options.reporter,
reporterOptions: options.reporterOptions,
record: options.record,
key: options.key,
parallel: options.parallel,
group: options.group,
tag: options.tag,
});
});
program
.command('open')
.description('launch test runner UI')
.option(
'-cf, --configFile <path>',
'specify a path to a JSON file where configuration values are set',
)
.action(options => {
open({
configFile: options.configFile,
});
});
program.parse(process.argv);