apollo-storybook-decorator icon indicating copy to clipboard operation
apollo-storybook-decorator copied to clipboard

Testing loading state and network failure

Open jgoux opened this issue 5 years ago • 2 comments

Hello,

I'd like to test my screens in their loading or network failure states.

How could I achieve that using apollo-storybook-decorator?

Thanks for your help.

EDIT : Maybe we could expose the delay function https://github.com/abhiaiyer91/apollo-storybook-decorator/blob/master/packages/apollo-storybook-core/src/index.js#L14 so we would be able to have :

  • no delay at all
  • a delay with a successful promise
  • a delay with a rejection (network failure)

EDIT 2: Ok I just saw that I can already pass delayMs to apolloLinkOptions! The loading issue is solved! 🎆 What about network failure?

jgoux avatar Sep 05 '18 15:09 jgoux

Do you mind sharing how you did that? --> Ok I just saw that I can already pass delayMs to apolloLinkOptions!

dilab avatar Oct 16 '19 10:10 dilab

@dilab

To add a delay: decorators: [ apolloStorybookDecorator({ apolloLinkOptions: { delayMs: 10000 }, typeDefs: schema, mocks: { Query: () => { return { users: () => [] }; } } }) ]

to add an error state: decorators: [ apolloStorybookDecorator({ typeDefs: schema, mocks: { Query: () => { return { users: () => Promise.reject('Error') }; } } }) ]

asilluron avatar Jan 01 '20 20:01 asilluron