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

Showcase runtime handlers in E2E examples #104

Open
nergro opened this issue Feb 23, 2024 · 2 comments
Open

Showcase runtime handlers in E2E examples #104

nergro opened this issue Feb 23, 2024 · 2 comments

Comments

@nergro
Copy link

nergro commented Feb 23, 2024

In the Remix + MSW example there is only one example with handlers that return 200.
But how should MSW be used with handlers that return 400, 500?
It's not clear how to use resetHandlers() or dynamic mock scenarios within a Remix app.

Trying to import ant reset handlers in a test doesn't work, because the server instance is only working within a entry.server.tsx file.

@kettanaito
Copy link
Member

Hi, @nergro. This is a fantastic suggestion. I think where the examples fall flat right now is that they don't mention how to use request handler overrides (.use()). We need to add at least one example of a response override to each example.

@kettanaito kettanaito changed the title Remix + MSW + Playwright Showcase runtime handlers in E2E examples Jun 25, 2024
@joshuaellis
Copy link

Bumping this, is there any guidance on how to do this? Modifying the current example test to look like:

test('receives mocked responses in loaders', async ({ page }) => {
  server.use(
    http.get('https://api.example.com/user', () => {
      return HttpResponse.error()
    }),
  )

  await page.goto('/', { waitUntil: 'networkidle' })

  const greeting = page.locator('#server-side-greeting')
  await expect(greeting).toHaveText('Hello, John!')
})

doesn't do anything so the test still passes. I've not been able to find anything, it feels like a bug but from seeing this, maybe it isn't?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants