When I run npm run test:jest all the tests pass, but when I run when I meteor npm run test:jest I get the error:
● Test suite failed to run
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object.<anonymous> (client/CounterComponent.test.tsx:5:35)
Thank you for whatever help/insight you can give to this issue.
I know it doesn’t solve your problem but I just ran meteor npm test (Jest) on one of my apps and the tests ran just fine (except for a part of my app that used Proxies, which aren’t available Meteor’s Node).
I encountered this error as well, as @manuel said it’s because Meteor is using node 4 and in order to parse some newer syntax in your tests without babel you need to use a newer version of node. Luckily the new Meteor 1.6 uses node 8 and it’s very stable, I’ve been using the Meteor 1.6 betas for awhile now without a hitch. So if you’re able to upgrade to a beta release, your jest tests will run fine.
Then you can run meteor npm run test:jest and it will work. I wouldn’t ever recommend running npm for a Meteor project directly, you should always use meteor npm.
Thanks a lot @efrancis and @manuel . I’m going to take your advice and upgrade to the 1.6 beta. I’ve been looking forward to getting off node4 for a while!