UNPKG

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