Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

create-react-app #71

Closed
lifeiscontent opened this issue Dec 30, 2016 · 9 comments
Closed

create-react-app #71

lifeiscontent opened this issue Dec 30, 2016 · 9 comments

Comments

@lifeiscontent
Copy link

When using a default create-react-app for storyshots, it seems to break.

I've got this code in src/Storyshots.test.js

import initStoryshots from 'storyshots';
initStoryshots();

the error in the test is

Test suite failed to run

    evalmachine.<anonymous>:1
    (function (exports, require, module, __filename, __dirname) { import { configure } from '@kadira/storybook';
                                                                  ^^^^^^
    SyntaxError: Unexpected token import
@lifeiscontent
Copy link
Author

figured it out, I needed a .babelrc that reflected the same presets as create react app

@roonyh
Copy link
Contributor

roonyh commented Dec 30, 2016

Glad it works! storyshots comes pre transpiled. So I think this is unrelated to storyshots. Anyway reopen if needed.

@roonyh roonyh closed this as completed Dec 30, 2016
@kedoska
Copy link

kedoska commented Jan 12, 2017

I have the same issue.
@lifeiscontent where did you set up the .babelrc?

in my __tests__ directory i have one file, storyshots.js

import initStoryshots from 'storyshots'
initStoryshots({
  suit: 'ComponentStories'
})

when i run npm run test-storybook everything works just fine
but, when i run npm test or, in my case CI=true npm test it fails like this

screenshot from 2017-01-12 15 35 31

my project was created with create-react-app

@arunoda arunoda reopened this Jan 13, 2017
@Fatxx
Copy link

Fatxx commented Feb 2, 2017

Any solution here? Get in the same error

@Fatxx
Copy link

Fatxx commented Feb 2, 2017

Could this issue be related to the command react-scripts test --env=jsdom ? Which we use to run tests?

@marc-rutkowski
Copy link

@kedoska, @Fatxx, as mentioned by @lifeiscontent, providing a basic .babelrc file (containing the following snippet) into the project root folder, solves the problem.

{
  "presets": ["es2015", "react"]
}

Let us know if it works for you.

@irnc
Copy link

irnc commented Mar 14, 2017

Please have a look at #67 (review) which added code related to babel config. The root cause for that issue seems to be in usage of babelConfig variable before its declaration.

@baptistemanson
Copy link

We were not able to get storyshots working at the same time as storybook and create-react-app using the workaround.
:(.

@irnc
Copy link

irnc commented Mar 18, 2017

@baptistemanson For a workaround, you could move from ES6 to ES5 in .storybook/config.js, i.e. use requite instead of import, so unconfigured Babel would just pass without an error on unknown syntax.

Note, that original error is about unknown syntax in .storybook/config.js, not in Storyshots.test.js.

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

No branches or pull requests

9 participants