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 c808901 commit 51c3929
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Fixes

- `[jest-validate]` Show suggestion only when unrecognized cli param is longer than 1 character ([#10604](https://github.com/facebook/jest/pull/10604))
- `[jest-validate]` Validate `testURL` as CLI option ([#10595](https://github.com/facebook/jest/pull/10595))

### Chore & Maintenance

Expand Down
13 changes: 13 additions & 0 deletions packages/jest-validate/src/__tests__/validateCLIOptions.test.js
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
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 51c3929

Please sign in to comment.