I have a utility.js which uses program arguments through process.argv
.
When I run jest -t 'utility-spec' --arg1 value1 --arg2 value2
it's throwing exception. Failed to run the test.
(node:8956) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ● Unrecognized CLI Parameters:
Following options were not recognized: ["arg1", "arg2"]
Just ran into the same question and found this answer:
Jest doesn't accept node arguments unfortunately. I recommend testing your utility by making a programmatic interface. You can also overwrite process.argv in your test before requiring your module.
Issue 5089
Seems like it's not possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With