Skip to content

Commit b0c16bd

Browse files
fix: validate testURL as CLI option (#10595)
1 parent c808901 commit b0c16bd

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

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

910
### Chore & Maintenance
1011

packages/jest-validate/src/__tests__/validateCLIOptions.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ test('validates yargs special options', () => {
1919
expect(validateCLIOptions(argv, options)).toBe(true);
2020
});
2121

22+
test('validates testURL', () => {
23+
const options = {
24+
testURL: {
25+
description: 'This option sets the URL for the jsdom environment.',
26+
type: 'string',
27+
},
28+
};
29+
const argv = {
30+
testURL: 'http://localhost',
31+
};
32+
expect(validateCLIOptions(argv, options)).toBe(true);
33+
});
34+
2235
test('fails for unknown option', () => {
2336
const options = ['$0', '_', 'help', 'h'];
2437
const argv = {

packages/jest-validate/src/validateCLIOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default function validateCLIOptions(
7979
const unrecognizedOptions = Object.keys(argv).filter(
8080
arg =>
8181
!allowedOptions.has(camelcase(arg)) &&
82+
!allowedOptions.has(arg) &&
8283
(!rawArgv.length || rawArgv.includes(arg)),
8384
[],
8485
);

0 commit comments

Comments
 (0)