apollo-storybook-decorator
apollo-storybook-decorator copied to clipboard
Testing loading state and network failure
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?
Do you mind sharing how you did that?
--> Ok I just saw that I can already pass delayMs to apolloLinkOptions!
@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') }; } } }) ]