Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 2e24f77

Browse files
committed
realtime: Improve testing framework
We were using mocha which presented some challenges and less than good experience when it came to testing. We're moving to vitest and we're also using Typescript in our testing to easily catch some of the typing issues that might arise earlier. We're also adding a coverage so later we can setup CI to take that into consideration.
1 parent 3058d0f commit 2e24f77

File tree

12 files changed

+2541
-1588
lines changed

12 files changed

+2541
-1588
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
docs/v2
44
.env
55
.nyc_output
6+
coverage/

package-lock.json

Lines changed: 1970 additions & 1085 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
"repository": "https://github.com/supabase/realtime-js",
2424
"author": "Supabase",
2525
"license": "MIT",
26+
"type": "module",
2627
"scripts": {
2728
"clean": "rimraf dist docs/v2",
2829
"format": "prettier --write \"{src,test}/**/*.ts\"",
2930
"build": "run-s clean format build:*",
3031
"build:main": "tsc -p tsconfig.json",
3132
"build:module": "tsc -p tsconfig.module.json",
32-
"mocha": "node -r esm node_modules/.bin/mocha ./test/**/*.js -r jsdom-global/register",
33-
"test": "run-s clean build mocha",
33+
"test": "vitest run",
34+
"test:watch": "vitest",
35+
"coverage": "vitest run --coverage",
3436
"docs": "typedoc src/index.ts --out docs/v2",
3537
"docs:json": "typedoc --json docs/v2/spec.json --excludeExternals src/index.ts"
3638
},
@@ -41,18 +43,19 @@
4143
"ws": "^8.14.2"
4244
},
4345
"devDependencies": {
46+
"@vitest/coverage-v8": "^2.0.5",
4447
"eslint": "^7.0.0",
4548
"esm": "^3.2.25",
4649
"jsdom": "^16.7.0",
4750
"jsdom-global": "3.0.0",
48-
"mocha": "^8.0.1",
4951
"mock-socket": "^9.0.3",
5052
"npm-run-all": "^4.1.5",
5153
"nyc": "^15.1.0",
5254
"prettier": "^2.1.2",
5355
"semantic-release-plugin-update-version-in-files": "^1.1.0",
5456
"sinon": "^9.0.2",
5557
"typedoc": "^0.22.16",
56-
"typescript": "^4.0.3"
58+
"typescript": "^4.0.3",
59+
"vitest": "^2.0.5"
5760
}
5861
}

src/RealtimeClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ export default class RealtimeClient {
176176
})
177177
return
178178
}
179-
180179
if (NATIVE_WEBSOCKET_AVAILABLE) {
181180
this.conn = new WebSocket(this._endPointURL())
182181
this.setupConnection()

0 commit comments

Comments
 (0)