Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validate testURL as CLI option #10595

Merged
merged 1 commit into from Oct 8, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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