Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/cli/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ export function validateInput(argv) {
return 'Error: You have a miss match between number of alias for groups and URLs.';
}

const connectivityEngines = ['external', 'throttle', 'humble'];
if (
argv.browsertime.connectivity &&
argv.browsertime.connectivity.engine !== undefined &&
!connectivityEngines.includes(argv.browsertime.connectivity.engine)
) {
return (
'Error: Unknown connectivity engine "' +
argv.browsertime.connectivity.engine +
'". Choose one of: ' +
connectivityEngines.join(', ') +
'.'
);
}

if (
argv.browsertime.connectivity &&
argv.browsertime.connectivity.engine === 'humble' &&
Expand Down
17 changes: 17 additions & 0 deletions test/cliTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ test(`CLI should silently ignore the removed summary boxes options`, async t =>
'Should not validate the removed summary boxes options'
);
});

test(`CLI should reject an unknown connectivity engine`, async t => {
let stderr = '';
let exitCode = 0;
try {
await runSitespeed([
'--browsertime.connectivity.engine',
'tc',
'https://www.sitespeed.io'
]);
} catch (error) {
stderr = error.stderr;
exitCode = error.code;
}
t.not(exitCode, 0, 'Should exit with error code');
t.true(stderr.includes('Unknown connectivity engine "tc"'));
});
Loading