MCPcopy
hub / github.com/tinyhttp/tinyhttp / InitAppAndTest

Function InitAppAndTest

test_helpers/initAppAndTest.ts:6–25  ·  view source on GitHub ↗
(
  handler: Handler,
  route?: string,
  method = 'get',
  settings: ConstructorParameters<typeof App>[0] = {}
)

Source from the content-addressed store, hash-verified

4import { makeFetch } from 'supertest-fetch'
5
6export const InitAppAndTest = (
7 handler: Handler,
8 route?: string,
9 method = 'get',
10 settings: ConstructorParameters<typeof App>[0] = {}
11) => {
12 const app = new App(settings)
13
14 if (route) {
15 app[method.toLowerCase()](route, handler)
16 } else {
17 app.use(handler)
18 }
19
20 const server = app.listen()
21
22 const fetch = makeFetch(server)
23
24 return { fetch, app, server }
25}

Callers 10

jsonp.test.tsFile · 0.90
request.test.tsFile · 0.90
app.test.tsFile · 0.90
response.test.tsFile · 0.90
ip-filter.test.tsFile · 0.90
markdown.test.tsFile · 0.90
pug.test.tsFile · 0.90
cors.test.tsFile · 0.90
ping.test.tsFile · 0.90
getSession.test.tsFile · 0.90

Calls 2

useMethod · 0.95
listenMethod · 0.95

Tested by

no test coverage detected