Mathspy / gatsby-storybook-jest-starter

A Gatsby starter based on default with added Storybook and Jest configurations
MIT License
46 stars 11 forks source link

__PATH_PREFIX__ #7

Closed eric-personal closed 6 years ago

eric-personal commented 6 years ago

Thanks for posting this starter. When running storybook http://localhost:6006/ I get error for header and layout.stories.js and header.stories.js

I'm getting error :

__PATH_PREFIX__ is not defined
            ReferenceError: __PATH_PREFIX__ is not defined

Any idea why this might be happening ?

Mathspy commented 6 years ago

It looks like Gatsby now uses __PATH_PREFIX__ internal in any environment, so it should be mocked inside .storybook/config.js like this:

global.__PATH_PREFIX__ = ''
// window.___push was renamed to window.___navigate, has to do this renaming too or storybook would error on clicking links
window.___navigate = pathname => {
  action('NavigateTo:')(pathname)
}
Mathspy commented 6 years ago

Fixed in #8 for future users. In case anyone else encounters this, please apply the changes I mentioned above

Thanks for reporting :heart: and please reopen in case these changes doesn't fix it for you!