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

storybook-chrome-screenshot does not support "undefined". thrown when scs used with Storyshots #53

Closed
Quramy opened this issue Jun 6, 2018 · 2 comments · Fixed by #54

Comments

@Quramy
Copy link
Member

Quramy commented Jun 6, 2018

Hi. I'm attempting to use both SCS and Storyshots add-ons in my production project. storybook-chrome-screenshot exits successfully but jest was failed. The full jest log is the following:

$ NODE_ENV=test jest storyshots.js
 => Loading custom .babelrc
 FAIL  frontend/storyshots.js
  ● Test suite failed to run

    storybook-chrome-screenshot does not support "undefined".

      at Object.<anonymous> (node_modules/storybook-chrome-screenshot/lib/withScreenshot.js:20:15)
      at Object.<anonymous> (node_modules/storybook-chrome-screenshot/lib/index.js:6:24)
      at newRequire (node_modules/@storybook/addon-storyshots/dist/require_context.js:76:12)
      at evalmachine.<anonymous>:224:34
      at runWithRequireContext (node_modules/@storybook/addon-storyshots/dist/require_context.js:102:3)
      at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/index.js:120:35)
      at Object.<anonymous> (frontend/storyshots.js:27:31)

Are there somebody whose some workarounds?

  • .storybook/config.js
import { configure, addDecorator } from '@storybook/react'
import bgs from '#/storybookDecorators/backgrounds'
import { initScreenshot, withScreenshot } from 'storybook-chrome-screenshot'

import 'babel-polyfill'

function loadStories() {
  const req = require.context('../src', true, /\.stories\.jsx$/)
  req.keys().forEach(filename => req(filename))
}

addDecorator(initScreenshot())
addDecorator(bgs())
addDecorator(withScreenshot())
configure(loadStories, module)
  • Entry point for Storyshots:
/* eslint-disable */
import initStoryshots from '@storybook/addon-storyshots'

// Workaround for https://github.com/facebook/react/issues/11565#issuecomment-368877149
const ReactDOM = require('react-dom')
const React = require('react')
ReactDOM.createPortal = node => React.createElement('portal-dummy', null, node)

initStoryshots()
@Quramy
Copy link
Member Author

Quramy commented Jun 6, 2018

It's caused by https://github.com/tsuyoshiwada/storybook-chrome-screenshot/blob/master/src/withScreenshot.ts#L25 I think it's better to return noop decorator by default rather than to throw exception.

@tsuyoshiwada How about it ?

@wadackel
Copy link
Collaborator

wadackel commented Jun 8, 2018

Hi @Quramy, I'm sorry that response was delayed 😢

It seems that there is no problem returning noop decorator!

FYI: At the time of implementation, we threw an exception to specify the unsupported framework.

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

Successfully merging a pull request may close this issue.

2 participants