github-actions
released this
11 Oct 09:01
·
122 commits
to v1.x-2022-07
since this release
Minor Changes
-
Special thank you to @kcarra for adding new mocked Providers for making testing easier! (#2224) by @blittle
- 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'}); }); });
- 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;
- Add
-
Updated the Storefront API version of Hydrogen to the
2022-10
release. (#2208) by @frehnerThis 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 to2022-10
as soon as possible.For more information about the Storefront API, refer to:
- The versioning documentation
- The
2022-10
release notes. Take note that Hydrogen never used theMoney
fields internally, so the breaking change listed there does not affect Hydrogen.
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 becomeCartProvider
requiring no code changes.To try this new cart provider:
import {CartProviderV2} from '@shopify/hydrogen/experimental';