VulcanJS/vulcan-next

Use MSW for API mocking in tests

eric-burel opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Mocking graphql queries is annoying, and we use specific solution.

Describe the solution you'd like
Use the same lib for all frontend request mocks.

  • Drafted a first example in Storybook, for the SmartForm (FormContainer) in Vulcan NPM
  • Check that preview.js still loads correctly in Jest after adding msw
  • Extend install to Jest, by creating a server on startup
  • Cleanup reusable helper (declarative mocks to MSW mocks)
  • Add MSW to Cypress? We already have cy.intercept but MSW might be used to intercept ssr requests as well
  • Add MSW in both Vulcan Next and Vulcan NPM

Describe alternatives you've considered
Apollo Mock Client: not bad.
But MSW seems to become the standard for both Rest and graphql, because it catches calls at a lower level: https://mswjs.io/docs/getting-started/mocks/graphql-api

Additional context
Testing with Next discussion: vercel/next.js#28173 (comment)

Done for Vulcan NPM, needs to be copied over Vulcan Next