Fix failing tests

This commit is contained in:
sayhiben
2025-01-19 23:05:44 -08:00
parent 37a3a29474
commit 1dfd638389
3 changed files with 5343 additions and 6380 deletions

View File

@@ -17,5 +17,5 @@ module.exports = {
coveragePathIgnorePatterns: ['/node_modules/'], coveragePathIgnorePatterns: ['/node_modules/'],
collectCoverage: true, collectCoverage: true,
coverageReporters: ['json', 'lcov', 'text', 'clover'], coverageReporters: ['json', 'lcov', 'text', 'clover'],
testEnvironment: 'jsdom' testEnvironment: 'node'
}; };

11701
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -20,8 +20,8 @@ describe('streamwall server', () => {
const adminUsername = 'admin' const adminUsername = 'admin'
const adminPassword = 'password' const adminPassword = 'password'
const hostname = 'localhost' const hostname = 'localhost'
const port = 8081 let port = 0
const baseURL = `http://${hostname}:${port}` let baseURL = `http://localhost:${port}`
let auth let auth
let clientState let clientState
@@ -62,17 +62,27 @@ describe('streamwall server', () => {
onMessage, onMessage,
stateDoc, stateDoc,
})) }))
request = supertest(server)
// Wait for the server to actually start so we can read its actual port
const address = server.address()
port = address.port
// Now you can build the real baseURL for supertest
baseURL = `http://localhost:${port}`
request = supertest(baseURL)
auth.on('state', (authState) => { auth.on('state', (authState) => {
clientState.update({ auth: authState }) clientState.update({ auth: authState })
}) })
}) })
afterEach(() => { afterEach(async () => {
server.close()
for (const ws of sockets) { for (const ws of sockets) {
ws.close() ws.close()
} }
if (server) {
await new Promise((resolve) => server.close(resolve))
}
}) })
function socket(options) { function socket(options) {