You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I 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.
@martinschayna can you upgrade to Node 6 where it is available by default? I don't think we should change how node is invoked; the flags are there for a reason (the feature is experimental in the version of node you are using).
$ yarn test
yarn test v0.20.3
node node_modules/.bin/jest --bad-jest-arg
Unrecognized options: bad-jest-arg, badJestArg
Reacted by Jiri Spac, Oleg Maslov, Benji Marinacci, Adi Kurniawan, Vitaly Aminev, Valentin Cocaud, artsiompeshko, Shaun Cutts, Ken Collins, Panaos Alisandratos and 1 more
@tkrotoff, that doesn't work when passing the --experimental-modules flag to node:
% node --experimental-modules node_modules/.bin/jest
(node:208569) ExperimentalWarning: The ESM module loader is experimental.
FAIL ./index.test.mjs
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
[...]
Details:
/home/dandv/esmjest/index.test.mjs:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { foo} from './lib';
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
My index.test.mjs has import { foo } from './lib'.
Activity
gaearon commentedon Sep 2, 2016
I think we should enable
--harmony_proxiesby default. How can we do this?cpojer commentedon Sep 4, 2016
@martinschayna can you upgrade to Node 6 where it is available by default? I don't think we should change how node is invoked; the flags are there for a reason (the feature is experimental in the version of node you are using).
gaearon commentedon Sep 4, 2016
Ah, I didn't realize it just works in Node 6. Let's close then.
tkrotoff commentedon Feb 15, 2017
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:
metaskills commentedon Jul 18, 2018
@tkrotoff Thank you!
dandv commentedon Oct 10, 2018
@tkrotoff, that doesn't work when passing the
--experimental-modulesflag to node:My
index.test.mjshasimport { foo } from './lib'.PS: See also overwriting argv.