From 63da15eb18065ef6c419f073c95fec6ef5541652 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 3 Jun 2021 09:06:51 +0200 Subject: Use random port for mock servers in tests --- shared/extra-utils/plugins/mock-blocklist.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'shared/extra-utils') diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts index 50e2289f1..d18f8224f 100644 --- a/shared/extra-utils/plugins/mock-blocklist.ts +++ b/shared/extra-utils/plugins/mock-blocklist.ts @@ -1,5 +1,6 @@ import * as express from 'express' import { Server } from 'http' +import { randomInt } from '@shared/core-utils' type BlocklistResponse = { data: { @@ -14,14 +15,15 @@ export class MockBlocklist { private server: Server initialize () { - return new Promise(res => { + return new Promise(res => { const app = express() app.get('/blocklist', (req: express.Request, res: express.Response) => { return res.json(this.body) }) - this.server = app.listen(42100, () => res()) + const port = 42201 + randomInt(1, 100) + this.server = app.listen(port, () => res(port)) }) } -- cgit v1.2.3