Reputation: 2052
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"]
Upvotes: 4
Views: 6619
Reputation: 129
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.
Seems like it's not possible.
Upvotes: 2