blob: bc1a9ce9155051c86446b6c6a81fdda69dd3da70 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import express from 'express'
import { Server } from 'http'
import { getPort, randomListen, terminateServer } from './shared.js'
export class MockHTTP {
private server: Server
async initialize () {
const app = express()
app.get('/*', (req: express.Request, res: express.Response, next: express.NextFunction) => {
return res.sendStatus(200)
})
this.server = await randomListen(app)
return getPort(this.server)
}
terminate () {
return terminateServer(this.server)
}
}
|