Skip to content
Compare
Choose a tag to compare
@github-actions github-actions released this 11 Oct 09:01
· 122 commits to v1.x-2022-07 since this release
4838a95

Minor Changes

  • Special thank you to @kcarra for adding new mocked Providers for making testing easier! (#2224) by @blittle

    1. Add ServerRequestProvider mock for testing server components:
    import useServerHook from './useServerHook.server'; // Server hook to test
    import {test, vi} from 'vitest';
    import {renderHook} from '@testing-library/react-hooks';
    import {ShopifyProvider} from '@shopify/hydrogen';
    import {MockedServerRequestProvider} from '@shopify/hydrogen/testing';
    
    describe('useServerHook', () => {
      test('mocked ServerRequest Context', () => {
        const wrapper = ({children}: {children: React.ReactElement}) => (
          <MockedServerRequestProvider>
            <ShopifyProvider shopifyConfig={mockShopifyConfig}>
              {children}
            </ShopifyProvider>
          </MockedServerRequestProvider>
        );
        const {result} = renderHook(() => useServerHook(), {wrapper});
        expect(result.current).toEqual({status: 'active'});
      });
    });
    1. Add ShopifyTestProviders mock for easier testing client components and using client components in other contexts, like Storybook:
    import {ComponentMeta, ComponentStory} from '@storybook/react';
    import React from 'react';
    import BoxCardUI from './BoxCard.ui';
    import {ShopifyTestProviders} from '@shopify/hydrogen/testing';
    
    export default {
      title: 'Components/BoxCard',
      component: BoxCardUI,
      decorators: [],
    } as ComponentMeta<typeof BoxCardUI>;
    
    const Template: ComponentStory<typeof BoxCardUI> = (args) => {
      return (
        <ShopifyTestProviders>
          <BoxCardUI {...args} /> // This component imports import{' '}
          {(Image, Link, Money)} from '@shopify/hydrogen'
        </ShopifyTestProviders>
      );
    };
    
    export const BoxCard = Template.bind({});
    BoxCard.args = mockShopifyProduct;
  • Updated the Storefront API version of Hydrogen to the 2022-10 release. (#2208) by @frehner

    This is a backwards-compatible change; if you are still on the 2022-07 version, you may stay on that version without any issues. However, it is still recommended that you upgrade to 2022-10 as soon as possible.

    For more information about the Storefront API, refer to:

Patch Changes

  • Experimental version of a new cart provider is ready for beta testing. (#2219) by @lordofthecactus

    CartProviderV2 fixes race conditions with our current cart provider. After beta, CartProviderV2 will become CartProvider requiring no code changes.

    To try this new cart provider:

    import {CartProviderV2} from '@shopify/hydrogen/experimental';