Error Unexpected token (Object spread) when running jest with --coverage OR transform key
See original GitHub issueNot entirely sure if this is an issue with jest or ts-jest, but ts-jest seemed more likely so opening the issue here.
Issue
When I run jest with coverage turned on jest --coverage and the tranform key present in package.json
e.g.:
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
every test that involves an object spread operator fails.
If I either:
- run jest without
--coverageor - run jest without the
transformkey present in package.json
all tests pass fine (in the second case, minus of course typescript tests, which I need ts-jest’s transform for 😬 )
I’m running: ts-jest: 21.2.4 jest: 21.2.1 node: v8.9.0 npm: 5.6.0
I am not using any kind of babel config, although while investigating this problem I tried using babel-plugin-transform-object-rest-spread, but it didn’t seem to have made a difference.
Minimal Repo
Link to a minimal repo that reproduces this issue. There’s also a branch that shows what happens when transform is removed from package.json
Travis is configured on this repo. Relevant build
Additional background info
Before using ts-jest, I had this problem with core jest as well, but then a new release of jest fixed the problem and everything worked as expected. The PR that fixed it was this one: https://github.com/facebook/jest/pull/4519
Any thoughts on what the problem might be? 🙇
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (4 by maintainers)

Top Related StackOverflow Question
@wilhelmklopp I haven’t looked at this yet but I’m hoping to find some time after work today.
it could be, and this is just conjecture, because jest processes everything using babel whereas instanbul doesn’t.