Skip to content

Commit

Permalink
refactor(tests): use WebSocketServer
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Oct 21, 2021
1 parent 1c00653 commit 33cc33b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion benchmark/servers/ws7.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ws from 'ws7';
const WebSocketServer = ws.Server;
import { ports } from './ports.mjs';
import { useServer } from '../../lib/use/ws.mjs';
import { schema } from './schema.mjs';

const server = new ws.Server({
const server = new WebSocketServer({
port: ports.ws7,
path: '/graphql',
});
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/utils/tservers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import http from 'http';
import { schema, pong } from '../fixtures/simple';
import { ServerOptions, Context } from '../../server';

import ws from 'ws';
import ws, { WebSocketServer } from 'ws';
import uWS from 'uWebSockets.js';
import Fastify from 'fastify';
import fastifyWebsocket from 'fastify-websocket';
Expand Down Expand Up @@ -98,12 +98,12 @@ async function getAvailablePort() {

export async function startRawServer(): Promise<{
url: string;
server: ws.Server;
server: WebSocketServer;
dispose: () => Promise<void>;
}> {
const path = '/raw';
const port = await getAvailablePort();
const server = new ws.Server({ port, path });
const server = new WebSocketServer({ port, path });

// sockets to kick off on teardown
const sockets = new Set<ws>();
Expand Down Expand Up @@ -141,7 +141,7 @@ export async function startWSTServer(
const path = '/simple';
const emitter = new EventEmitter();
const port = await getAvailablePort();
const wsServer = new ws.Server({ port, path });
const wsServer = new WebSocketServer({ port, path });

// sockets to kick off on teardown
const sockets = new Set<ws>();
Expand Down

0 comments on commit 33cc33b

Please sign in to comment.