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

[BUG] CartTestProviders is not available for testing #2323

Open
LewisN opened this issue Nov 15, 2022 · 0 comments
Open

[BUG] CartTestProviders is not available for testing #2323

LewisN opened this issue Nov 15, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@LewisN
Copy link

LewisN commented Nov 15, 2022

Describe the bug
Components that rely on a Cart Context cannot be rendered in Storybook. This error is shown:

Error: Expected a Cart Context, but no Cart Context was found

CartTestProviders already exists as a mock Provider which could resolve this, but it isn't exported by @shopify/hydrogen/testing.

To Reproduce

  1. Add Storybook to a Hydrogen project (v1.5.0 and above)
  2. Create a story rendering the Header.client component from the Hydrogen demo store (or any component that uses the useCart hook and relies on a Cart Context)
  3. Run storybook and try to load the story

Expected behaviour
I should be able to import CartTestProviders from @shopify/hydrogen/testing and use this in a decorator to provide Cart Context (the same way I can with ShopifyTestProviders). Component should render in Storybook without errors.

Screenshots
Screenshot 2022-11-15 at 15 55 07

Additional context

  • Hydrogen version: 1.5.0+
@LewisN LewisN added the bug Something isn't working label Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant