1 | const openSmokeTests = require('../lib/smoke/open');
|
2 |
|
3 | module.exports = (program) => {
|
4 |
|
5 | const collectHeaders = (val, memo) => {
|
6 | memo.push(val);
|
7 | return memo;
|
8 | };
|
9 |
|
10 | program
|
11 | .command('open [sets...]')
|
12 | .option('-b, --breakpoint [value]', 'o-grid breakpoint to set viewport to')
|
13 | .option('-c, --config [value]', 'Path to config file used to test. Defaults to ./test/smoke.js')
|
14 | .option('-H, --host [value]', 'Set the hostname to use for all tests')
|
15 | .option('--header [value]', 'Request headers to be sent with every request. e.g. "X-Api-Key: 1234"', collectHeaders, [])
|
16 |
|
17 | .description('Starts an instance of Chromium with all the URLs from the smoke test open')
|
18 | .action((sets, opts) => {
|
19 | const globalHeaders = {};
|
20 | opts.header.forEach(header => {
|
21 | const split = header.split(':');
|
22 | if(split.length > 1) {
|
23 | globalHeaders[split[0].trim()] = split[1].trim();
|
24 | }
|
25 | });
|
26 |
|
27 | delete opts.header;
|
28 | opts.headers = globalHeaders;
|
29 |
|
30 | openSmokeTests(opts, sets);
|
31 | });
|
32 | };
|