question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error Unexpected token (Object spread) when running jest with --coverage OR transform key

See original GitHub issue

Not 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 --coverage or
  • run jest without the transform key 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kulshekharcommented, Dec 12, 2017

@wilhelmklopp I haven’t looked at this yet but I’m hoping to find some time after work today.

0reactions
kulshekharcommented, Dec 16, 2017

it could be, and this is just conjecture, because jest processes everything using babel whereas instanbul doesn’t.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Unexpected token (Object spread) when running jest ...
every test that involves an object spread operator fails. If I either: run jest without --coverage or; run jest without the transform key...
Read more >
javascript - Jest error Unexpected token ... (ES6)
In babel 7, babel-plugin-transform-object-rest-spread will report error: SpreadProperty has been renamed to SpreadElement . So I use:
Read more >
Spread Operator Jest Encountered An Unexpected Token - ADocLib
App made with VueCLI helper of Vuex mapState became so error if we try to use in Vueloader: Unexpected token error for using...
Read more >
How I Fixed The Unexpected Token Error In Jest
So for the Jest tests to run, it first needs to be transpiled by Babel. If you don't get it properly transpiled, you'll...
Read more >
syntaxerror: unexpected token postman, syntaxerror: unexpected ...
this is the error Jest encountered an unexpected token This usually means that ... will need to add the babel-plugin-transform-object-rest-spread transform.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found