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/'],
collectCoverage: true,
coverageReporters: ['json', 'lcov', 'text', 'clover'],
testEnvironment: 'jsdom'
testEnvironment: 'node'
};

11693
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 adminPassword = 'password'
const hostname = 'localhost'
const port = 8081
const baseURL = `http://${hostname}:${port}`
let port = 0
let baseURL = `http://localhost:${port}`
let auth
let clientState
@@ -62,17 +62,27 @@ describe('streamwall server', () => {
onMessage,
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) => {
clientState.update({ auth: authState })
})
})
afterEach(() => {
server.close()
afterEach(async () => {
for (const ws of sockets) {
ws.close()
}
if (server) {
await new Promise((resolve) => server.close(resolve))
}
})
function socket(options) {