Skip to content

Commit d5f5cb5

Browse files
validate testURL as CLI option
1 parent 999ee46 commit d5f5cb5

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- `[jest-console]` Add `Console` constructor to `console` object ([#10502](https://github.com/facebook/jest/pull/10502))
3030
- `[jest-globals]` Fix lifecycle hook function types ([#10480](https://github.com/facebook/jest/pull/10480))
3131
- `[jest-runtime]` Remove usage of `vm.compileFunction` due to a performance issue ([#10586](https://github.com/facebook/jest/pull/10586))
32+
- `[jest-validate]` Validate `testURL` as CLI option ([#10595](https://github.com/facebook/jest/pull/10595))
3233

3334
### Chore & Maintenance
3435

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)