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

ReferenceError: window is not defined when executing initStoryshots() #909

Closed
flanamacca opened this issue Apr 17, 2017 · 6 comments
Closed

Comments

@flanamacca
Copy link

When using jest to init initStoryshots (as per the guide), I am stumped with the following error. Sadly all of the code references that used to exist for storyshots seem to go to 404 pages.

` FAIL .\Storyshots.test.js
● Test suite failed to run

ReferenceError: window is not defined

  at evalmachine.<anonymous>:17:1
  at runWithRequireContext (node_modules\storyshots\dist\require_context.js:104:3)
  at testStorySnapshots (node_modules\storyshots\dist\index.js:72:35)
  at Object.<anonymous> (Storyshots._test_.js:2:26)
  at process._tickCallback (internal\process\next_tick.js:109:7)`
@shilman
Copy link
Member

shilman commented Apr 17, 2017

@flanamacca which code references are you referring to? The storyshots repo has moved here:

https://github.com/storybooks/storybook/tree/master/packages/storyshots

We are in the process of transitioning to a mono-repo to simplify version management and testing.

@flanamacca
Copy link
Author

Hey @shilman This part on that pge.

import initStoryshots from 'storyshots';
initStoryshots(); <!-- when this runs with nothing but the default configuration i was getting this error. Now i had to setup a lot of just settings to get working.

When i do the basic installation with create-react-app and run it, it doesn't work either (since it's not configured to run through any preprocessor).

PASS src/App.test.js
FAIL tests/Storyshots.test.js
● Test suite failed to run

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

@flanamacca
Copy link
Author

Found the solution is that unlike in some other jest setups, you need to define your windows as global objects in the config file.

@beauknowssoftware
Copy link

Sorry for coming back to a closed issue, but I'm also experiencing this. @flanamacca , do you happen to have a code sample that shows your solution?

@leojh
Copy link

leojh commented Apr 5, 2018

This error started happening for me all of a sudden out of nowhere :|

@OBrian16
Copy link

OBrian16 commented Apr 4, 2019

` ReferenceError: error is not defined

  83 |           className={'reactSelect'}
  84 |         />
> 85 |         {error && <strong>{error}</strong>}
     |          ^
  86 |       </div>
  87 |     })

`
I'm getting the same error. Anyone with a solution?

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

No branches or pull requests

5 participants