Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
- name: Install
run: yarn install --immutable
- name: Test
run: yarn test --forceExit
run: yarn test
16 changes: 0 additions & 16 deletions babel.config.js

This file was deleted.

10 changes: 0 additions & 10 deletions jest.config.js

This file was deleted.

16 changes: 3 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"lint:prettier": "prettier -c .",
"lint": "yarn lint:eslint && yarn lint:prettier",
"type-check": "tsc --noEmit",
"test": "jest",
"test": "vitest",
"bench:start-servers": "NODE_ENV=production node benchmark/servers/index.mjs",
"bench": "k6 run benchmark/k6.mjs",
"build:esm": "tsc -b tsconfig.esm.json && node scripts/esm-post-process.mjs",
Expand All @@ -107,35 +107,24 @@
"graphql": ">=0.11 <=16"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/preset-env": "^7.24.4",
"@babel/preset-typescript": "^7.24.1",
"@fastify/websocket": "^9.0.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/eslint": "^8.56.10",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.12",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"babel-jest": "^29.7.0",
"bun-types": "^1.1.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"fastify": "^4.26.2",
"fastify-websocket": "4.2.2",
"glob": "^10.3.12",
"graphql": "^16.8.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-jasmine2": "^29.7.0",
"jsdom": "^25.0.1",
"prettier": "^3.2.5",
"replacestream": "^4.0.3",
"rollup": "^4.14.3",
Expand All @@ -146,6 +135,7 @@
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.4.5",
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.43.0",
"vitest": "^2.1.8",
"ws": "8.12.0",
"ws7": "npm:ws@^7.5.9"
},
Expand Down
6 changes: 0 additions & 6 deletions src/__tests__/jest.d.ts

This file was deleted.

5 changes: 5 additions & 0 deletions tests/__snapshots__/client.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`should report close error even if complete message followed 1`] = `""error" message expects the 'payload' property to be an array of GraphQL errors, but got "malformed""`;

exports[`should report close error even if complete message followed 2`] = `""error" message expects the 'payload' property to be an array of GraphQL errors, but got "malformed""`;
91 changes: 91 additions & 0 deletions tests/__snapshots__/common.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`should report invalid message "" with descriptive error 1`] = `[Error: Message is expected to be an object, but got string]`;

exports[`should report invalid message %j with descriptive error 1`] = `[Error: Message is expected to be an object, but got array]`;

exports[`should report invalid message {"id":"","type":"complete"} with descriptive error 1`] = `[Error: "complete" message requires a non-empty 'id' property]`;

exports[`should report invalid message {"id":"","type":"error"} with descriptive error 1`] = `[Error: "error" message requires a non-empty 'id' property]`;

exports[`should report invalid message {"id":"","type":"next"} with descriptive error 1`] = `[Error: "next" message requires a non-empty 'id' property]`;

exports[`should report invalid message {"id":"","type":"subscribe"} with descriptive error 1`] = `[Error: "subscribe" message requires a non-empty 'id' property]`;

exports[`should report invalid message {"id":"id","type":"error","payload":""} with descriptive error 1`] = `[Error: "error" message expects the 'payload' property to be an array of GraphQL errors, but got ""]`;

exports[`should report invalid message {"id":"id","type":"error","payload":[]} with descriptive error 1`] = `[Error: "error" message expects the 'payload' property to be an array of GraphQL errors, but got []]`;

exports[`should report invalid message {"id":"id","type":"error","payload":[{"iam":"invalid"}]} with descriptive error 1`] = `[Error: "error" message expects the 'payload' property to be an array of GraphQL errors, but got [{"iam":"invalid"}]]`;

exports[`should report invalid message {"id":"id","type":"error","payload":{}} with descriptive error 1`] = `[Error: "error" message expects the 'payload' property to be an array of GraphQL errors, but got {}]`;

exports[`should report invalid message {"id":"id","type":"error"} with descriptive error 1`] = `[Error: "error" message expects the 'payload' property to be an array of GraphQL errors, but got undefined]`;

exports[`should report invalid message {"id":"id","type":"next","payload":""} with descriptive error 1`] = `[Error: "next" message expects the 'payload' property to be an object, but got string]`;

exports[`should report invalid message {"id":"id","type":"next"} with descriptive error 1`] = `[Error: "next" message expects the 'payload' property to be an object, but got undefined]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":""} with descriptive error 1`] = `[Error: "subscribe" message expects the 'payload' property to be an object, but got string]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":[]} with descriptive error 1`] = `[Error: "subscribe" message expects the 'payload' property to be an object, but got array]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"operationName":{},"query":""}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'operationName' property to be a string or nullish or missing, but got object]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"operationName":0,"query":""}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'operationName' property to be a string or nullish or missing, but got number]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"query":"","extensions":""}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'extensions' property to be a an object or nullish or missing, but got string]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"query":"","extensions":0}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'extensions' property to be a an object or nullish or missing, but got number]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"query":"","variables":""}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'variables' property to be a an object or nullish or missing, but got string]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"query":{}}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'query' property to be a string, but got object]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{"query":0}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'query' property to be a string, but got number]`;

exports[`should report invalid message {"id":"id","type":"subscribe","payload":{}} with descriptive error 1`] = `[Error: "subscribe" message payload expects the 'query' property to be a string, but got undefined]`;

exports[`should report invalid message {"id":"id","type":"subscribe"} with descriptive error 1`] = `[Error: "subscribe" message expects the 'payload' property to be an object, but got undefined]`;

exports[`should report invalid message {"id":0,"type":"complete"} with descriptive error 1`] = `[Error: "complete" message expects the 'id' property to be a string, but got number]`;

exports[`should report invalid message {"id":0,"type":"subscribe"} with descriptive error 1`] = `[Error: "subscribe" message expects the 'id' property to be a string, but got number]`;

exports[`should report invalid message {"type":""} with descriptive error 1`] = `[Error: Message is missing the 'type' property]`;

exports[`should report invalid message {"type":"complete"} with descriptive error 1`] = `[Error: "complete" message expects the 'id' property to be a string, but got undefined]`;

exports[`should report invalid message {"type":"connection_ack","payload":""} with descriptive error 1`] = `[Error: "connection_ack" message expects the 'payload' property to be an object or nullish or missing, but got ""]`;

exports[`should report invalid message {"type":"connection_init","payload":""} with descriptive error 1`] = `[Error: "connection_init" message expects the 'payload' property to be an object or nullish or missing, but got ""]`;

exports[`should report invalid message {"type":"connection_init","payload":0} with descriptive error 1`] = `[Error: "connection_init" message expects the 'payload' property to be an object or nullish or missing, but got "0"]`;

exports[`should report invalid message {"type":"error"} with descriptive error 1`] = `[Error: "error" message expects the 'id' property to be a string, but got undefined]`;

exports[`should report invalid message {"type":"next"} with descriptive error 1`] = `[Error: "next" message expects the 'id' property to be a string, but got undefined]`;

exports[`should report invalid message {"type":"next"} with descriptive error 2`] = `[Error: "next" message expects the 'id' property to be a string, but got undefined]`;

exports[`should report invalid message {"type":"nuxt"} with descriptive error 1`] = `[Error: Invalid message 'type' property "nuxt"]`;

exports[`should report invalid message {"type":"ping","payload":0} with descriptive error 1`] = `[Error: "ping" message expects the 'payload' property to be an object or nullish or missing, but got "0"]`;

exports[`should report invalid message {"type":"subscribe"} with descriptive error 1`] = `[Error: "subscribe" message expects the 'id' property to be a string, but got undefined]`;

exports[`should report invalid message {"type":0} with descriptive error 1`] = `[Error: Message is missing the 'type' property]`;

exports[`should report invalid message {} with descriptive error 1`] = `[Error: Message is missing the 'type' property]`;

exports[`should report invalid message {} with descriptive error 2`] = `[Error: Message is missing the 'type' property]`;

exports[`should report invalid message 0 with descriptive error 1`] = `[Error: Message is expected to be an object, but got number]`;

exports[`should report invalid message 9 with descriptive error 1`] = `[Error: Message is expected to be an object, but got number]`;

exports[`should report invalid message undefined with descriptive error 1`] = `[Error: Message is expected to be an object, but got function]`;

exports[`should report invalid message undefined with descriptive error 2`] = `[Error: Message is expected to be an object, but got function]`;

exports[`should report invalid message undefined with descriptive error 3`] = `[Error: Message is expected to be an object, but got function]`;
Loading
Loading