@dunx/testing 2.4.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,17 @@
1
1
  # @dunx/testing
2
2
 
3
- The container an app already has, with named bindings **replaced in place**, plus a
4
- real `Bun.serve` on port 0. No mocking framework, no fake request object, no
5
- in-memory transport - Bun binds a socket in about a millisecond, so the thing under
6
- test is the thing that ships.
3
+ The container an app already has, with named bindings **replaced in place**, plus
4
+ a real `Bun.serve` on port 0. Bun binds a socket in about a millisecond, so the
5
+ thing under test is the thing that ships: there is no mocking framework, no fake
6
+ request object and no in-memory transport.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ bun add -d @dunx/testing
12
+ ```
13
+
14
+ ## Usage
7
15
 
8
16
  ```ts
9
17
  import { provide } from '@dunx/core';
@@ -27,140 +35,29 @@ const { status, body } = await server.json<User[]>('api/users');
27
35
  await server.close();
28
36
  ```
29
37
 
30
- ## Overrides replace; they never append
31
-
32
- This is the whole design, and it follows from how `@dunx/core` applies an override:
33
- by **substitution into the binding that already exists**, never by appending a
34
- registration that has to out-rank the real one.
35
-
36
- A module is a scope, and `providers` are private to it. So a test override cannot be
37
- an extra module appended at the end that wins - an appended module's providers are
38
- invisible to every scope that does not import it, being the scope the
39
- code under test resolves from.
40
-
41
- `createTestApp` therefore builds the same scope graph the app would have and
42
- substitutes by token inside it. Three consequences worth relying on:
43
-
44
- - **An override replaces the binding in every scope that holds it.** A test stubbing
45
- `Logger` does not have to know how many modules bind it, and does not have to name
46
- a scope. Where two scopes genuinely bind one token differently and only one is
47
- meant, resolve through the module you care about instead.
48
- - **An override naming a token nobody binds is an error** rather than a silent no-op. A
49
- typo'd token would otherwise leave the suite asserting against the real provider
50
- it thought it had swapped, the failure mode this package exists to
51
- prevent.
52
- - **The discarded provider is never instantiated.** Its `useFactory` never runs and
53
- its `onInit` never fires. Overriding the database does not open a connection to
54
- the real database - that is the one guarantee here that a hand-rolled fixture
55
- usually gets wrong, and `app.test.ts` proves it with a factory that throws if it
56
- is ever called.
57
-
58
- `Logger` and `RequestContext` are overridable too, even though no module binds
59
- them: core offers a default for each after every module, and the substitution
60
- applies there as well.
61
-
62
- ## API
63
-
64
- | Export | What it is |
65
- | --------------------------- | ----------------------------------------------------------------------- |
66
- | `createTestApp(options)` | `Promise<App>` - the core container, overrides applied |
67
- | `createTestServer(options)` | `Promise<TestServer>` - the same, plus `Bun.serve` on port 0 and a client |
68
- | `testClient(url)` | `TestClient` - the request helpers against any base URL |
69
- | `testRoot(modules)` | The synthetic root module, for driving `HttpFactory` yourself |
70
- | `RecordingLogger` | A `Logger` that keeps entries instead of writing them |
71
-
72
- `modules` takes one module ref or several; several become the `imports` of one
73
- synthetic root, so no fixture module has to be written by hand. Anything a module
74
- ref can be works - a class, or a `DynamicModule` from a `forRoot`.
75
-
76
- `TestServer` is a `TestClient` plus `app` (the real `HttpApp`, for
77
- `app.get(...)`) and `close()`.
78
-
79
- `createTestServer` passes `HttpOptions` through, with two differences: `port`
80
- is always 0, and **`requestLogging` defaults to `false`** - it is on by default
81
- in production for good reasons, none of which apply to a suite that would
82
- otherwise print one JSON line per assertion. Pass `requestLogging: true` to
83
- test the logging itself.
84
-
85
- Everything else is **absent unless passed**, and `middleware` and `onError`
86
- decide what the application is: forget them and the fixture has no global
87
- guards and the default error mapper, and answers 200 where production answers
88
- 401. Export one `httpOptions(config)` and spread it into both `main.ts` and
89
- every suite.
90
-
91
- Omitting `middleware` in a graph that declares a `Middleware` no `@UseGuards`
92
- attaches warns on `console.warn`; `middleware: []` says the omission is
93
- deliberate.
94
-
95
- ### The client
96
-
97
- Two methods, because a third would be the start of an assertion DSL:
98
-
99
- ```ts
100
- const { status, headers, body } = await server.json<Page>('notes?limit=10');
101
- await server.json('notes/7', { method: 'PATCH', json: { title: 'edited' } });
102
- const image = await server.request('avatars/7.png'); // the raw Response
103
- ```
104
-
105
- `json` on the init object is serialized and sets `content-type: application/json`
106
- unless `headers` already carries one - one option for every verb, rather than a
107
- `post`/`put`/`patch` triple. `json()` reads the body as text before parsing, so a
108
- route that answered 204, HTML or a plain-text error fails with the status,
109
- content-type and body rather than with `JSON.parse`'s message.
38
+ ## What is here
110
39
 
111
- ### RecordingLogger
40
+ The [Testing guide](../../docs/guide/11-testing.md) is canonical.
112
41
 
113
- The `Logger` contract is seven levels of three overloads each, so every suite that
114
- wants a quiet app would otherwise hand-write the same thirty lines:
42
+ | Export | What it does |
43
+ | ------------------ | ---------------------------------------------------------------- |
44
+ | `createTestApp` | The container, with overrides applied before anything resolves |
45
+ | `createTestServer` | The same, behind a real `Bun.serve` on port 0 |
46
+ | `testClient` | The fetch-and-parse plumbing against a base url |
115
47
 
116
- ```ts
117
- const logger = new RecordingLogger();
118
- await createTestApp({
119
- modules: [PaymentsModule],
120
- overrides: [provide(Logger, { useValue: logger })],
121
- });
122
- expect(logger.at(LogLevel.ERROR)).toEqual([]);
123
- ```
124
-
125
- It records; it does not interpret. No level filtering, no error promotion, no
126
- merging of extras - those are `@arkv/logger`'s behaviour, and asserting against a
127
- reimplementation of them would prove nothing.
128
-
129
- ## Not here
130
-
131
- - **A fluent assertion DSL** (`expect(res).toHaveStatus(200)`, supertest-style
132
- chaining). `status` and a parsed `body` read fine through `expect` already, and a
133
- matcher library would be a second vocabulary to learn for no new capability.
134
- - **Provider spies / partial mocks.** `provide(Token, { useValue })` with a class
135
- the test wrote is smaller than any mocking API, and `bun test` already ships
136
- `mock()` and `spyOn()` for a method on an instance the container handed back.
137
- - **A `providers` key on the options.** `{ modules, overrides }` is the shape, on
138
- purpose: a suite tests the modules an app actually ships. A fixture class that
139
- needs binding goes in a two-line `@Module`, which is also where it would live if
140
- it were real.
141
- - **A fake HTTP dispatcher.** It could only exercise the parts of the request path
142
- dunx wrote, and not the parts Bun owns - route matching, params, method
143
- dispatch, upgrades. The real server is cheaper than the lie.
144
- - **Database fixtures, transactional rollback, seeding.** That is drizzle's
145
- surface rather than this package's. `@dunx/infra/db` binds an in-memory `bun:sqlite`
146
- with the same driver as production, which is a better fixture than a mock.
147
- - **A websocket client.** Bun implements `WebSocket` natively, and a gateway test
148
- is `new WebSocket(server.url.replace('http', 'ws') + '/chat')`. Wrapping that
149
- would add nothing.
48
+ ## Notes
150
49
 
151
- ## Install it as a devDependency
152
-
153
- ```bash
154
- bun add -d @dunx/testing
155
- ```
50
+ - An override replaces the binding in **every scope that holds it**, so a test
51
+ stubbing `Logger` need not know how many modules bind it. Naming a token
52
+ nobody binds is an error rather than a silent no-op.
53
+ - The replacement happens before anything resolves, so the discarded provider is
54
+ never constructed: its `useFactory` never runs and its `onInit` never fires,
55
+ which makes overriding a database safe.
56
+ - Request logging and boot logging are off unless asked for.
57
+ - An `HttpOptions` field not passed is absent; nothing is inherited from
58
+ production. `middleware` and `onError` change what the application does, so
59
+ pass the same object `main.ts` passes.
156
60
 
157
- `@dunx/core` and `@dunx/http` are `dependencies`, at a **caret** range. What matters
158
- is that your app and this package resolve to **one copy of `@dunx/core`** - two
159
- copies means two `Logger` classes and two `RequestContext` classes, so tokens that
160
- match nothing and overrides that silently replace nothing. A caret range hoists to
161
- the copy your app already has.
61
+ ## License
162
62
 
163
- Peers would have expressed that better, and were tried first: `bun run --filter '*'`
164
- derives its build order from `dependencies` only, so a peer-only manifest cannot be
165
- built in this monorepo at all. The reasoning and the measurement are in
166
- [architecture/packaging.md](../../docs/architecture/packaging.md), "Test harness".
63
+ MIT
package/dist/index.js CHANGED
@@ -154,6 +154,3 @@ export {
154
154
  testClient,
155
155
  testRoot
156
156
  };
157
-
158
- //# debugId=542D5DFC23443AC664756E2164756E21
159
- //# sourceMappingURL=index.js.map
package/dist/server.d.ts CHANGED
@@ -18,11 +18,10 @@ export interface TestServer extends TestClient {
18
18
  close(): Promise<void>;
19
19
  }
20
20
  /**
21
- * A **real** `Bun.serve` on port 0, with the same override semantics as
22
- * {@link createTestApp}. Nothing is faked: `Bun.serve` binds in about a
23
- * millisecond, and a fake would only be able to prove the parts of the request
24
- * path dunx wrote rather than the parts Bun owns - routing, params, method
25
- * dispatch, upgrades.
21
+ * A real `Bun.serve` on port 0, with the same override semantics as
22
+ * {@link createTestApp}. `Bun.serve` binds in about a millisecond, and a fake
23
+ * could only prove the parts of the request path dunx wrote rather than the parts
24
+ * Bun owns - routing, params, method dispatch, upgrades.
26
25
  *
27
26
  * ```ts
28
27
  * const server = await createTestServer({ modules: [ApiModule], prefix: 'api' });
@@ -30,15 +29,11 @@ export interface TestServer extends TestClient {
30
29
  * await server.close();
31
30
  * ```
32
31
  *
33
- * Request logging and boot logging are both **off** unless asked for: they are on by
34
- * default in production for good reasons, none of which apply to a suite that would
35
- * print one JSON line per assertion and one route table per file.
32
+ * Request logging and boot logging are off unless asked for, since a suite would
33
+ * otherwise print one JSON line per assertion and one route table per file.
36
34
  *
37
- * **An `HttpOptions` field not passed is absent, not inherited from production.**
38
- * `middleware` (where global guards live) and `onError` are the two that change
39
- * what the application does, so pass the same object `main.ts` passes - one
40
- * exported `httpOptions(config)` spread into both. Omitting `middleware` in a graph
41
- * that declares a `Middleware` no `@UseGuards` attaches writes one line to
42
- * `console.warn`; `middleware: []` says the omission is deliberate.
35
+ * An `HttpOptions` field not passed is absent, not inherited from production.
36
+ * `middleware` and `onError` change what the application does, so pass the same
37
+ * object `main.ts` passes. `middleware: []` says the omission is deliberate.
43
38
  */
44
39
  export declare const createTestServer: (options: TestServerOptions) => Promise<TestServer>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunx/testing",
3
- "version": "2.4.0",
3
+ "version": "3.0.0",
4
4
  "description": "Test harness for dunx apps: a container with providers replaced in place, and a real Bun.serve on port 0",
5
5
  "keywords": [
6
6
  "bun",
@@ -51,8 +51,8 @@
51
51
  "@dunx/http": "workspace:*"
52
52
  },
53
53
  "peerDependencies": {
54
- "@dunx/core": "^2.4.0",
55
- "@dunx/http": "^2.4.0",
54
+ "@dunx/core": "^3.0.0",
55
+ "@dunx/http": "^3.0.0",
56
56
  "@types/bun": ">=1.3.0"
57
57
  },
58
58
  "peerDependenciesMeta": {
@@ -61,6 +61,6 @@
61
61
  }
62
62
  },
63
63
  "engines": {
64
- "bun": ">=1.3.0"
64
+ "bun": ">=1.4.0"
65
65
  }
66
66
  }
package/dist/index.js.map DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/app.ts", "../src/client.ts", "../src/logger.ts", "../src/server.ts"],
4
- "sourcesContent": [
5
- "import {\n AppFactory,\n type App,\n type AppOptions,\n type DynamicModule,\n type ModuleRef,\n type Registration,\n} from '@dunx/core';\n\n/**\n * The synthetic root. A named class rather than an object literal for the same\n * reason `@dunx/http`'s `HttpModule` is one: it is what a duplicate-binding error\n * would name if the harness itself ever bound anything.\n */\nclass TestModule {}\n\nexport interface TestAppOptions extends AppOptions {\n /**\n * The graph under test. A single module, or several - they become the `imports`\n * of one synthetic root, so no fixture module has to be written by hand.\n */\n readonly modules: ModuleRef | readonly ModuleRef[];\n}\n\nconst isList = (\n modules: ModuleRef | readonly ModuleRef[],\n): modules is readonly ModuleRef[] => Array.isArray(modules);\n\n/**\n * The root `createTestApp` boots. Exported for the case the harness deliberately\n * does not cover: configuring an `HttpApp` before `listen()` (`enableCors`, `use`,\n * `set`), which means calling `HttpFactory.create(testRoot(modules), …)` directly.\n */\nexport const testRoot = (\n modules: ModuleRef | readonly ModuleRef[],\n): DynamicModule => ({\n module: TestModule,\n imports: isList(modules) ? modules : [modules],\n});\n\n/** `exactOptionalPropertyTypes` separates an absent key from an undefined one. */\nexport const appOptions = (\n overrides: readonly Registration[] | undefined,\n): AppOptions => (overrides ? { overrides } : {});\n\n/**\n * The container the app under test would have, with the bindings named in\n * `overrides` **replaced in place**.\n *\n * ```ts\n * const app = await createTestApp({\n * modules: [UsersModule],\n * overrides: [provide(Clock, { useValue: new FixedClock('2026-01-01') })],\n * });\n * ```\n *\n * Replacement, not addition: the discarded provider is never instantiated, so an\n * async `useFactory` that would open the real database never runs. An override\n * naming a token nobody binds throws instead of passing silently.\n */\nexport const createTestApp = (options: TestAppOptions): Promise<App> =>\n AppFactory.create(testRoot(options.modules), appOptions(options.overrides));\n",
6
- "export interface JsonInit extends RequestInit {\n /**\n * Serialized as the request body, with `content-type: application/json` set\n * unless `headers` already carries one. Covers every verb, so there is no\n * `post()`/`put()`/`patch()` triple here. Takes precedence over `body`.\n */\n readonly json?: unknown;\n}\n\nexport interface JsonResponse<T> {\n readonly status: number;\n readonly headers: Headers;\n readonly body: T;\n}\n\nexport interface TestClient {\n /** The server's base URL, as `listen()` returned it. */\n readonly url: string;\n /** The raw `Response` - for bytes, HTML, or asserting on a header. */\n request(path?: string, init?: JsonInit): Promise<Response>;\n /** Status, headers and parsed body in one await, which is the common assertion. */\n json<T = unknown>(path?: string, init?: JsonInit): Promise<JsonResponse<T>>;\n}\n\nconst target = (base: string, path: string): URL => new URL(path, base);\n\nconst withJson = (init: JsonInit): RequestInit => {\n const { json, ...rest } = init;\n if (json === undefined) return rest;\n\n const headers = new Headers(init.headers);\n if (!headers.has('content-type')) {\n headers.set('content-type', 'application/json');\n }\n return { ...rest, headers, body: JSON.stringify(json) };\n};\n\n/**\n * `fetch` against one base URL, plus the JSON round-trip every suite otherwise\n * rewrites. Deliberately not an assertion DSL: it returns values that `expect`\n * already reads well, so failures point at the assertion rather than at a matcher\n * this package would have to define.\n *\n * `createTestServer` returns one of these already bound to the server it started;\n * this is here for an app booted some other way.\n */\nexport const testClient = (url: string): TestClient => ({\n url,\n request: (path = '', init: JsonInit = {}) =>\n fetch(target(url, path), withJson(init)),\n json: async <T>(path = '', init: JsonInit = {}): Promise<JsonResponse<T>> => {\n const response = await fetch(target(url, path), withJson(init));\n // Read as text first: a route that answered 204, HTML or a plain-text error\n // would otherwise fail with `JSON.parse`'s message and none of the context\n // needed to see why.\n const text = await response.text();\n try {\n return {\n status: response.status,\n headers: response.headers,\n body: JSON.parse(text) as T,\n };\n } catch {\n const body =\n text === ''\n ? 'an empty body'\n : `a ${response.headers.get('content-type') ?? 'typeless'} body:\\n\\n` +\n text.slice(0, 300);\n throw new Error(\n `${init.method ?? 'GET'} ${target(url, path).pathname} answered ` +\n `${response.status} with ${body}\\n\\nThat is not JSON - use request() ` +\n 'for a response that is not.',\n );\n }\n },\n});\n",
7
- "import { Logger, LogLevel, type LogMessage } from '@dunx/core';\n\nexport interface RecordedLog {\n readonly level: LogLevel;\n readonly message: LogMessage;\n readonly params: readonly unknown[];\n}\n\n/**\n * A {@link Logger} that keeps entries instead of writing them, so a suite can\n * assert on what was logged and stays quiet when it does not care.\n *\n * It is here because the contract is seven levels of three overloads each: every\n * suite that wants a silent logger would otherwise hand-write the same thirty\n * lines. Nothing is interpreted - no level filtering, no error promotion, no\n * merging of extras - because those are the backing logger's behaviour and\n * asserting against a reimplementation of them would prove nothing.\n *\n * ```ts\n * const logger = new RecordingLogger();\n * await createTestApp({\n * modules: [UsersModule],\n * overrides: [provide(Logger, { useValue: logger })],\n * });\n * expect(logger.at(LogLevel.WARN)).toHaveLength(0);\n * ```\n */\nexport class RecordingLogger extends Logger {\n /** Everything is recorded, so a suite can assert on a `verbose` call too. */\n readonly logLevel: LogLevel = LogLevel.VERBOSE;\n readonly entries: RecordedLog[] = [];\n\n verbose(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.VERBOSE, message, params);\n }\n\n debug(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.DEBUG, message, params);\n }\n\n info(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.INFO, message, params);\n }\n\n /** @deprecated Use {@link RecordingLogger.info}. Recorded as `info` either way. */\n log(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.INFO, message, params);\n }\n\n warn(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.WARN, message, params);\n }\n\n error(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.ERROR, message, params);\n }\n\n fatal(message: LogMessage, ...params: unknown[]): void {\n this.#record(LogLevel.FATAL, message, params);\n }\n\n at(level: LogLevel): readonly RecordedLog[] {\n return this.entries.filter((entry) => entry.level === level);\n }\n\n clear(): void {\n this.entries.length = 0;\n }\n\n #record(\n level: LogLevel,\n message: LogMessage,\n params: readonly unknown[],\n ): void {\n this.entries.push({ level, message, params });\n }\n}\n",
8
- "import {\n collectModules,\n readControllers,\n type Ctor,\n type ResolvedModule,\n} from '@dunx/core';\nimport {\n discoverRoutes,\n HttpFactory,\n type HttpApp,\n type HttpOptions,\n type Middleware,\n} from '@dunx/http';\nimport { appOptions, testRoot, type TestAppOptions } from './app.js';\nimport { testClient, type TestClient } from './client.js';\n\nexport interface TestServerOptions\n extends TestAppOptions, Omit<HttpOptions, 'port' | 'overrides'> {\n /**\n * `setGlobalPrefix`, applied before `listen()` so the client's URLs carry it.\n *\n * Explicitly `| undefined`, unlike the rest of the options: a suite that runs\n * the same fixture prefixed and unprefixed passes a variable here, and under\n * `exactOptionalPropertyTypes` that is otherwise a conditional spread. \"No\n * prefix\" and \"absent\" mean the same thing, so nothing is lost by allowing it.\n */\n readonly prefix?: string | undefined;\n}\n\nexport interface TestServer extends TestClient {\n readonly app: HttpApp;\n /** `app.shutdown()` - stops the server, then tears the container down. */\n close(): Promise<void>;\n}\n\nconst middlewareShaped = (ctor: Ctor<unknown>): boolean =>\n typeof (ctor.prototype as { handle?: unknown } | undefined)?.handle ===\n 'function';\n\n/** Every class provider in the graph that implements `Middleware`. */\nconst declaredMiddleware = (\n modules: readonly ResolvedModule[],\n): readonly Ctor<unknown>[] => {\n const found: Ctor<unknown>[] = [];\n for (const module of modules) {\n for (const entry of module.options.providers ?? []) {\n const ctor =\n typeof entry === 'function'\n ? entry\n : entry.provider.kind === 'class'\n ? entry.provider.ctor\n : undefined;\n if (ctor !== undefined && middlewareShaped(ctor)) found.push(ctor);\n }\n }\n return found;\n};\n\n/**\n * The guards `@UseGuards` already puts in the route table. They are not global, so\n * omitting `middleware` costs them nothing and warning about them would be noise.\n */\nconst scopedGuards = (\n app: HttpApp,\n modules: readonly ResolvedModule[],\n): ReadonlySet<Ctor<Middleware>> => {\n const applied = new Set<Ctor<Middleware>>();\n for (const module of modules) {\n for (const controller of readControllers(module)) {\n for (const route of discoverRoutes(app.get(controller) as object)) {\n for (const guard of route.guards ?? []) applied.add(guard);\n }\n }\n }\n return applied;\n};\n\n/**\n * The one silent way this harness can lie: `middleware` and `onError` default\n * away, so a suite that forgets them boots a server with no global guards and the\n * default error mapper, which still answers 200 where the application answers 401.\n * A first integration run of 12 pass / 10 fail is the reported cost of finding\n * that out by hand.\n *\n * So a `Middleware` implementation that is in the graph, is not attached by\n * `@UseGuards`, and was not passed here is worth one line on `console.warn` -\n * `console`, not the bound `Logger`, because a suite asserting on a\n * `RecordingLogger` should not see an entry the application never wrote.\n */\nconst warnAboutGlobals = (\n app: HttpApp,\n modules: readonly ResolvedModule[],\n): void => {\n const declared = declaredMiddleware(modules);\n if (declared.length === 0) return;\n const scoped = scopedGuards(app, modules);\n const orphaned = declared.filter(\n (ctor) => !scoped.has(ctor as Ctor<Middleware>),\n );\n if (orphaned.length === 0) return;\n\n console.warn(\n `createTestServer: ${orphaned.map((ctor) => ctor.name).join(', ')} ` +\n 'implement Middleware and are in the graph under test, but no `middleware` ' +\n 'was supplied. If they are global in main.ts then this fixture is not the ' +\n 'application: no global guard runs and `onError` is the default mapper. ' +\n 'Export one httpOptions(config) and give it to both, or pass ' +\n '`middleware: []` to say the omission is deliberate.',\n );\n};\n\n/**\n * A **real** `Bun.serve` on port 0, with the same override semantics as\n * {@link createTestApp}. Nothing is faked: `Bun.serve` binds in about a\n * millisecond, and a fake would only be able to prove the parts of the request\n * path dunx wrote rather than the parts Bun owns - routing, params, method\n * dispatch, upgrades.\n *\n * ```ts\n * const server = await createTestServer({ modules: [ApiModule], prefix: 'api' });\n * const { status, body } = await server.json('api/users');\n * await server.close();\n * ```\n *\n * Request logging and boot logging are both **off** unless asked for: they are on by\n * default in production for good reasons, none of which apply to a suite that would\n * print one JSON line per assertion and one route table per file.\n *\n * **An `HttpOptions` field not passed is absent, not inherited from production.**\n * `middleware` (where global guards live) and `onError` are the two that change\n * what the application does, so pass the same object `main.ts` passes - one\n * exported `httpOptions(config)` spread into both. Omitting `middleware` in a graph\n * that declares a `Middleware` no `@UseGuards` attaches writes one line to\n * `console.warn`; `middleware: []` says the omission is deliberate.\n */\nexport const createTestServer = async (\n options: TestServerOptions,\n): Promise<TestServer> => {\n const { modules, overrides, prefix, requestLogging, bootLogging, ...http } =\n options;\n\n const root = testRoot(modules);\n const app = await HttpFactory.create(root, {\n ...http,\n ...appOptions(overrides),\n requestLogging: requestLogging ?? false,\n // Off for the same reason: a suite that boots a server per file does not want a\n // route table per file. A suite asserting on the table asks for it.\n bootLogging: bootLogging ?? false,\n port: 0,\n });\n if (http.middleware === undefined)\n warnAboutGlobals(app, collectModules(root));\n if (prefix !== undefined) app.setGlobalPrefix(prefix);\n\n return {\n ...testClient(await app.listen()),\n app,\n close: () => app.shutdown(),\n };\n};\n"
9
- ],
10
- "mappings": ";;AAAA;AAAA;AAAA;AAAA;AAcA,MAAM,WAAW;AAAC;AAUlB,IAAM,SAAS,CACb,YACoC,MAAM,QAAQ,OAAO;AAOpD,IAAM,WAAW,CACtB,aACmB;AAAA,EACnB,QAAQ;AAAA,EACR,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,OAAO;AAC/C;AAGO,IAAM,aAAa,CACxB,cACgB,YAAY,EAAE,UAAU,IAAI,CAAC;AAiBxC,IAAM,gBAAgB,CAAC,YAC5B,WAAW,OAAO,SAAS,QAAQ,OAAO,GAAG,WAAW,QAAQ,SAAS,CAAC;;ACrC5E,IAAM,SAAS,CAAC,MAAc,SAAsB,IAAI,IAAI,MAAM,IAAI;AAEtE,IAAM,WAAW,CAAC,SAAgC;AAAA,EAChD,QAAQ,SAAS,SAAS;AAAA,EAC1B,IAAI,SAAS;AAAA,IAAW,OAAO;AAAA,EAE/B,MAAM,UAAU,I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