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(jest-validate): Allow deprecation warnings for unknown options #14499

Prev Previous commit
Next Next commit
docs: Add example of validating CLI options
  • Loading branch information
dj-stormtrooper committed Sep 11, 2023
commit 521931948fc759d02d84684bd8dfbb74891f0dfc
23 changes: 23 additions & 0 deletions packages/jest-validate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,26 @@ Custom Deprecation:

Documentation: http://custom-docs.com
```

## Example validating CLI arguments

```js
import {validate} from 'jest-validate';

validateCLIOptions(
argv,
{ ...allowedOptions, deprecatedOptions },
);
```

If `argv` contains a deprecated option that is not specifid in `allowedOptions`, `validateCLIOptions` will throw an error with the message specified in the `deprecatedOptions` config:

```bash
● collectCoverageOnlyFrom:

Option "collectCoverageOnlyFrom" was replaced by "collectCoverageFrom"

CLI Options Documentation: https://jestjs.io/docs/en/cli.html
```

If the deprecation option is still listed in the `allowedOptions` config, then `validateCLIOptions` will print the warning wihout throwing an error.
Loading
-