testIndex.js
const decache = require('decache');
export const parseCommand = function(passedArguments) {
decache('commander');
const program = require('commander');
program
.description('A CLI for the Tenon Node')
.option(
'-k, --key <key>',
'Tenode API key'
).option(
'-e, --endpoint <endpoint>',
'Tenon API endpoint'
).option(
'-i, --in [in]',
'Input file'
).option(
'-o, --out <out>',
'Output file'
).option(
'--config [config]',
'Tenode configuration file'
)
.option(
'-f, --format [format]',
'The format of the outputted data [json, html, xunit, csv]',
/^(json|html|xunit|csv)$/i
).option(
'-w, --wait-for [waitFor]',
'Delay, in milliseconds, for the Tenode tests',
parseFloat
).option(
'-l, --level [level]',
'The "lowest" WCAG level to test against',
/^(A|AA|AAA)$/i
).option(
'-c, --certainty [certainty]',
'Level of certainty of Tenode results [0, 20, 40, 60, 80, 100]',
/^(0|20|40|60|80|100)$/i
).option(
'-I, --importance [importance]',
'An optional value'
).option(
'-p, --priority [priority]',
'Filter for Tenode results, filtering out those with a lower priortiy',
/^(0|20|40|60|80|100)$/i
).option(
'-s, --store',
'Should Tenode store the results or not?'
).option(
'-d, --doc-id [docID]',
'A string of text used to identify the page being tested'
).option(
'-F, --fragment',
'This parameter allows you to identify the source string as only a fragment of a page',
).option(
'-P, --project-id [projectID]',
'A string you can supply to identify the tested document as part of a specific system'
).option(
'-u, --user-agent [uaString]',
'A user-agent to be supplied during Tenode tests'
).option(
'-H, --view-port-height [viewPortHeight]',
'The height of the headless browser viewport in Tenode tests',
parseFloat
).option(
'-W, --view-port-width [viewPortWidth]',
'The width of the headless browser viewport in Tenode tests',
parseFloat
).parse(passedArguments);
return program;
};
export const filteredOptions = function(program) {
return Object.keys(program).filter(function(opt) {
return [ 'commands',
'options',
'_execs',
'_allowUnknownOption',
'_args',
'_name',
'Command',
'Option',
'_description',
'_events',
'_eventsCount',
'rawArgs',
'args'].indexOf(opt) === -1;
});
};