Skip to content

Commit

Permalink
validate testURL as CLI option
Browse files Browse the repository at this point in the history
  • Loading branch information
victorphoenix3 committed Oct 8, 2020
1 parent 999ee46 commit 6ea17f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## master

- `[jest-validate]` Validate `testURL` as CLI option ([#10595](https://github.com/facebook/jest/pull/10595))

### Features

### Fixes
Expand Down
13 changes: 13 additions & 0 deletions packages/jest-validate/src/__tests__/validateCLIOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ test('validates yargs special options', () => {
expect(validateCLIOptions(argv, options)).toBe(true);
});

test('validates testURL', () => {
const options = {
testURL: {
description: 'This option sets the URL for the jsdom environment.',
type: 'string',
},
};
const argv = {
testURL: 'http://localhost',
};
expect(validateCLIOptions(argv, options)).toBe(true);
});

test('fails for unknown option', () => {
const options = ['$0', '_', 'help', 'h'];
const argv = {
Expand Down
1 change: 1 addition & 0 deletions packages/jest-validate/src/validateCLIOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default function validateCLIOptions(
const unrecognizedOptions = Object.keys(argv).filter(
arg =>
!allowedOptions.has(camelcase(arg)) &&
!allowedOptions.has(arg) &&
(!rawArgv.length || rawArgv.includes(arg)),
[],
);
Expand Down

0 comments on commit 6ea17f5

Please sign in to comment.