How to pass arguments to node in Jest tests?
See original GitHub issueI have tried to use builtin Jest in version 0.3.0
but need to use ES6 Proxy
object in test.
This can be done by passing argument --harmony_proxies
to node
and using harmony-reflect polyfill in test. I am able to import polyfill in tests, but it looks like it’s not possible to run jest
in node with any additional arguments.
I used to use this in package.json
:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "node --harmony_proxies node_modules/jest/bin/jest.js"
}
Now jest
is completely under the hood of react-scripts
, which is gooood 👍, but how can I pass arguments to node?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to send node command line arguments in jest test
Jest doesn't accept node arguments unfortunately. I recommend testing your utility by making a programmatic interface.
Read more >Jest CLI Options
If you run Jest via yarn test , you can pass the command line arguments directly as Jest arguments. Instead of: jest -u...
Read more >Jest: Passing custom arguments - Medium
Jest : Passing custom arguments · First try: Run jest with any argument · Second try: Google to the rescue? · The third...
Read more >How to pass command line options to Jest? - Knapsack Pro
Instead, use --updateSnapshot . If you want to pass arguments related to Node you should use NODE_OPTIONS environment variable. See example for ...
Read more >jest pass arguments to node, jest test with parameters, jest ...
jest pass arguments to node. Launching the Node.js process as: node process-args.js hello "Rahul Kumar" 123. Would generate the output: 0: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For people not using create-react-app and passing by… I do this in my package.json to pass arguments to Node and Jest (v18.1.0) :
You can verify that arguments are really treated by passing unknown/bad arguments:
@tkrotoff, that doesn’t work when passing the
--experimental-modules
flag to node:My
index.test.mjs
hasimport { foo } from './lib'
.PS: See also overwriting argv.