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

Where should storybook config file be placed? #1075

Closed
stereodenis opened this issue May 19, 2017 · 7 comments
Closed

Where should storybook config file be placed? #1075

stereodenis opened this issue May 19, 2017 · 7 comments

Comments

@stereodenis
Copy link
Contributor

I try to place config.js file to:
%project%/storybook
%project%/App (where __tests__ folder)

App/__tests__/Storyshots-spec.js
  ● Test suite failed to run

    storyshots is intended only to be used with storybook
@ndelangen
Copy link
Member

That message is given when storyshots cannot find either @storybook/react or @storybook/react-native in your package.json.

@stereodenis
Copy link
Contributor Author

stereodenis commented May 20, 2017

@ndelangen, what am I doing wrong?

#npm test
App/__tests__/Storyshots-spec.js
  ● Test suite failed to run

    Your test suite must contain at least one test.
      
      at onResult (node_modules/jest-cli/build/TestRunner.js:192:18)
      at process._tickCallback (internal/process/next_tick.js:109:7)
#Storyshots-spec.jsec.js
import initStoryshots from '@storybook/addon-storyshots'

initStoryshots()
#config.js
import { configure } from '@storybook/react-native'

configure(() => require('./stories'), module)
#stories/index.js
import React from 'react'
import { storiesOf, action, linkTo } from '@kadira/react-native-storybook'

import Welcome from './Welcome'
import OrderScene from '../../App/Scenes/OrderScene/presenter'

storiesOf('Welcome', module)
  .add('to Storybook', () => (
    <Welcome showApp={linkTo('Button')} />
  ))

for (const ticketingStatus of ['pending', 'return', 'error', 'success', 'none']) {
  for (const bookingStatus of ['pending', 'cancel', 'error', 'success']) {
    for (const paymentStatus of ['pending', 'refund', 'error', 'success', 'none']) {
      storiesOf('OrderScene', module)
        .add(`booking: ${bookingStatus}\n\npayment: ${paymentStatus}\n\nticketing: ${ticketingStatus}`, () => (
          <OrderScene
            {...{
              bookingStatus,
              ticketingStatus,
              paymentStatus,
              isPayuOrder: false,
              payuPending: false,
              canPay: true,
              passengers: [],
              cityFromName: 'Воронеж',
              cityToName: 'Воронеж',
              orderTripStartDate: '11.01.2017',
              orderTripEndDate: '11.01.2017',
              orderTripStartTime: '08:00',
              orderTripEndTime: '12:00',
            }}
            buyTicket={() => {}}
            returnTicket={() => {}}
            openPdf={() => {}}
          />
        ))
    }
  }
}

@shilman
Copy link
Member

shilman commented May 20, 2017

@stereodenis I'm not sure about the error, but I did spot one problem. You want:

orderStories =  storiesOf('OrderScene', module)
for( ... ) {
  for ...
    orderStories.add('name', () => <OrderScene ... />)
}

Otherwise it will overwrite the story each time through the for loop.

Does everything show up in Storybook OK?

@stereodenis
Copy link
Contributor Author

@ndelangen
I've clean my stories/index file

import React from 'react'
import { storiesOf, action, linkTo } from '@kadira/react-native-storybook'

import Welcome from './Welcome'

storiesOf('Welcome', module)
  .add('to Storybook', () => (
    <Welcome showApp={linkTo('Button')} />
  ))

but I still got the same

jest

 FAIL  App/__tests__/Storyshots-spec.js
  ● Test suite failed to run

    Your test suite must contain at least one test.
      
      at onResult (node_modules/jest-cli/build/TestRunner.js:192:18)

@ndelangen
Copy link
Member

ndelangen commented May 21, 2017

The error message you posted originally and are posting now are different!

That last message is related to jest finding a spec / test file with 0 it or test calls in it. A specfile without any tests causes jest to fail, because that should never happen:

why have a testfile but no tests in it?

Either delete the testfile or write some tests in it.

@stereodenis
Copy link
Contributor Author

@ndelangen I want to use my stories to test snapshots

@roman-holovin
Copy link

roman-holovin commented Aug 29, 2017

@stereodenis You are importing
import { storiesOf, action, linkTo } from '@kadira/react-native-storybook'
and it should be
import { storiesOf, action, linkTo } from '@storybook/react-native' or something like this.

I'm using react version, so check precise import for react-native yourself

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