Skip to content

How to test subscriptions? #165

@Sam-Kruglov

Description

@Sam-Kruglov

I'm getting "socket closed" with or without config with import { ws } from 'msw'.

Piece of my .storybook/preview.tsx:

parameters: {
  msw: {
    handlers: {
      graphql: createHandlerFromSchema(...)
    }
  },

Looks like createHandlerFromSchema already integrates with MSW but not for subscriptions, is that a bug? And somehow even if I try to configure msw.ws.link(...) it still has no effect. Either way please add an example to this repo

storybook params come from https://github.com/mswjs/msw-storybook-addon

I set up resolver for subscription query via rxjs.Subject that gets kicked off by calling a mutation (couldn't use PubSub from your demo because it has no built-in impl for browser and I already have rxjs). But I don't think that matters.

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