Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token ... after upgrading to 6.2.1 #192

Closed
albert-olive opened this issue Sep 25, 2018 · 9 comments
Closed

Unexpected token ... after upgrading to 6.2.1 #192

albert-olive opened this issue Sep 25, 2018 · 9 comments

Comments

@albert-olive
Copy link

Hi,

After upgrading to 6.2.1 all my tests breaks:

.../node_modules/jest-styled-components/src/toHaveStyleRule.js:104
    const normalizeOptions = ({ modifier, ...options }) =>
                                          ^^^
    SyntaxError: Unexpected token ...
t ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
      at Object.<anonymous> (node_modules/jest-styled-components/src/index.js:1:114)
      at Object.<anonymous> (src/setupTests.js:11:51)

And my setupTests.js:

import 'jest-enzyme';
import 'jest-styled-components';

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

My package versions are:

"styled-components": "3.2.3",
"jest-enzyme": "6.1.2",
"react": "16.5.2",

Anyone has the same problem?

Thanks

@mofax
Copy link

mofax commented Sep 26, 2018

just introduced jest-styled-components into a project, and got hit with this...

@aserrabl
Copy link

aserrabl commented Oct 3, 2018

I'm facing the same issue when adding it to a project. From which version are you updating @albert-olive? Tried also 6.0.0 with no luck. 5.0.1 works great.

My versions are
"react": "16.5.0", "jest": "21.2.1", "styled-components": "3.4.9"

@albert-olive
Copy link
Author

Hi @aserrabl, in my previous comment, you have my versions. Didn't updated yet because I'm having already this problem

@SarantopoulosKon
Copy link

I have the same issue, for what it's worth i've recently updated my project to create react app v2, could it be that?

"styled-components": "^3.4.9",
"polished": "^2.1.1",
"react": "^16.5.2",

@MicheleBertoli
Copy link
Member

Thanks for opening this issue, @albert-olive, and thanks for your comments, @mofax @aserrabl @SarantopoulosKon.

I assume you are using a version of node < 8.6, right?
Source: https://node.green/#ES2018-features-object-rest-spread-properties

@mofax
Copy link

mofax commented Oct 14, 2018 via email

@albert-olive
Copy link
Author

Me too @MicheleBertoli

@devrelm
Copy link
Contributor

devrelm commented Oct 15, 2018

The package.json can/should define the engines field to show a warning if a supported version of node is not installed.

https://docs.npmjs.com/files/package.json#engines

Alternatively (and preferably), toHaveStyleRule.js should be updated to not use a rest spread prop. Node 6 is still supported until April 2019, so it's probably best if we continue support for that as well.

@jdrub
Copy link

jdrub commented Oct 16, 2018

I ran into this too, for a quick temporary fix you can just tell jest to transform this package by adding the following line to your jest config:
"transformIgnorePatterns": ["/node_modules\/(?!(jest-styled-components)\/).*/"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants