Subscriptions-transport-ws: Integration tests

Created on 20 Jul 2017  路  3Comments  路  Source: apollographql/subscriptions-transport-ws

Hey Guys,
I'm trying to write some tests for my subscriptions. I have an express server
My implementation is simple

    SubscriptionServer.create({
        schema,
        execute,
        subscribe,
        onConnect: () => {
            console.log(' connected ');
        }

    }, {
        server,
        path: '/subscriptions',
    });

I'm using Redis pub/sub to subscribe and publish events
https://github.com/davidyaha/graphql-redis-subscriptions

Whats the best possible way to test this?
Do i have to make a separate websocket connection in my tests?

const client= new SubscriptionClient(`ws://localhost:3000/`, {
        reconnect: true,
      }, websocket);

and if i subscribe using SubscriptionClient, should that callback update with a response, if a pub/sub publish is called on that subscribe event.

Most helpful comment

Hi, i use SubscriptionClient on React-Native, and testing with Jest. It said:

Unable to find native implementation, or alternative implementation for WebSocket!

How we can mock and testing?

All 3 comments

Hi, i use SubscriptionClient on React-Native, and testing with Jest. It said:

Unable to find native implementation, or alternative implementation for WebSocket!

How we can mock and testing?

Can anyone help on this please?
do i create a WS with my express server?

        wsServer = new WebSocket.Server({
            server: myServer
        }); 

that doesnt seem to work, it complains that TypeError: this.wsImpl is not a constructor

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PetrSnobelt picture PetrSnobelt  路  3Comments

MoonTahoe picture MoonTahoe  路  5Comments

anilanar picture anilanar  路  5Comments

KaiWedekind picture KaiWedekind  路  4Comments

myyellowshoe picture myyellowshoe  路  6Comments