Skip to content

Showcase runtime handlers in E2E examples #104

Open

Description

@nergro

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.

Activity

  1. kettanaito commented on Mar 2, 2024

    @kettanaito
    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.

  2. changed the title [-]Remix + MSW + Playwright[/-] [+]Showcase runtime handlers in E2E examples[/+] on Jun 25, 2024
  3. joshuaellis commented on Jan 14, 2025

    @joshuaellis

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions