-
Notifications
You must be signed in to change notification settings - Fork 146
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
[V3] Remove cross-fetch
from template-retail-react-app
#1160
Conversation
beforeEach(() => { | ||
jest.resetModules() | ||
fetch.mockClear() | ||
const fetchMock = require('jest-fetch-mock') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we installing this package? Do we need this package? I tried this approach, and it does work without importing this library
let originalFetch
beforeEach(() => {
originalFetch = global.fetch
global.fetch = jest.fn(() =>
Promise.resolve({
json: jest.fn(),
ok: true
})
)
})
afterEach(() => {
global.fetch = originalFetch
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lib was already installed and in dev dependancies. But I'm not sure what it was used for before. I think it was used before MSW as added maybe?
Anyway, it doesn't hurt to use a mock fetch lib that was already installed, rather than a one off mock. It might give more flexibility in the future if we have tests that do more than mock a successful call.
* v3: fix: remove device-context and detect-device-type (#1168) Dependency updates (#1170) [Snyk] Security upgrade cosmiconfig from 7.1.0 to 8.0.0 (#1145) [V3] Remove `cross-fetch` from `template-retail-react-app` (#1160) [v3] Add suffix to ssr build files (#1158) Consume new version of the commerce-sdk-isomorphic to enable Phased Launches support HTTP Basic Auth (#1153) # Conflicts: # packages/commerce-sdk-react/package-lock.json # packages/internal-lib-build/package-lock.json # packages/pwa-kit-runtime/package-lock.json # packages/template-retail-react-app/package-lock.json
…xtensibility-algo-refactor + regen lockfiles * feature/template-extensibility: regen package lockfiles fix: remove device-context and detect-device-type (#1168) Dependency updates (#1170) [Snyk] Security upgrade cosmiconfig from 7.1.0 to 8.0.0 (#1145) [V3] Remove `cross-fetch` from `template-retail-react-app` (#1160) [v3] Add suffix to ssr build files (#1158) Consume new version of the commerce-sdk-isomorphic to enable Phased Launches support HTTP Basic Auth (#1153) # Conflicts: # package-lock.json # packages/commerce-sdk-react/package-lock.json # packages/internal-lib-build/package-lock.json # packages/my-extended-retail-app/package-lock.json # packages/pwa-kit-create-app/package-lock.json # packages/pwa-kit-dev/package-lock.json # packages/pwa-kit-react-sdk/package-lock.json # packages/pwa-kit-runtime/package-lock.json # packages/template-retail-react-app/app/hooks/use-einstein.test.js # packages/template-retail-react-app/package-lock.json # packages/template-typescript-minimal/package-lock.json # packages/test-commerce-sdk-react/package-lock.json
Description
We recently removed the
commerce-api
client code from the template, leaving behind the einstein implementation. Because einstein is only ever used on the client we don't need to usecross-fetch
, so we are removing it in this PR.Types of Changes
Changes
cross-fetch
from useEinstein hookHow to Test-Drive This PR
viewCategory
viewProduct
etc. This means things are still working.General