@dunx/testing 3.1.1 → 3.1.2
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/dist/index.js +7 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -90,7 +90,8 @@ import {
|
|
|
90
90
|
readControllers
|
|
91
91
|
} from "@dunx/core";
|
|
92
92
|
import {
|
|
93
|
-
HttpFactory
|
|
93
|
+
HttpFactory,
|
|
94
|
+
HttpOptionsProvider
|
|
94
95
|
} from "@dunx/http";
|
|
95
96
|
import { discoverRoutes } from "@dunx/http/internal";
|
|
96
97
|
var middlewareShaped = (ctor) => typeof ctor.prototype?.handle === "function";
|
|
@@ -117,7 +118,7 @@ var scopedGuards = (app, modules) => {
|
|
|
117
118
|
}
|
|
118
119
|
return applied;
|
|
119
120
|
};
|
|
120
|
-
var warnAboutGlobals = (app, modules) => {
|
|
121
|
+
var warnAboutGlobals = (app, modules, mapperIsDefault) => {
|
|
121
122
|
const declared = declaredMiddleware(modules);
|
|
122
123
|
if (declared.length === 0)
|
|
123
124
|
return;
|
|
@@ -125,7 +126,7 @@ var warnAboutGlobals = (app, modules) => {
|
|
|
125
126
|
const orphaned = declared.filter((ctor) => !scoped.has(ctor));
|
|
126
127
|
if (orphaned.length === 0)
|
|
127
128
|
return;
|
|
128
|
-
console.warn(`createTestServer: ${orphaned.map((ctor) => ctor.name).join(", ")} ` + "implement Middleware and are in the graph under test, but no `middleware` " + "was supplied. If they are global in main.ts then this fixture is not the
|
|
129
|
+
console.warn(`createTestServer: ${orphaned.map((ctor) => ctor.name).join(", ")} ` + "implement Middleware and are in the graph under test, but no `middleware` " + "was supplied and no HttpOptionsProvider bound any. If they are global in " + "main.ts then this fixture is not the application: no global guard runs" + (mapperIsDefault ? " and `onError` is the default mapper" : "") + ". Bind the same HttpOptionsProvider the application binds, or pass " + "`middleware: []` to say the omission is deliberate.");
|
|
129
130
|
};
|
|
130
131
|
var createTestServer = async (options) => {
|
|
131
132
|
const { modules, overrides, prefix, requestLogging, bootLogging, ...http } = options;
|
|
@@ -137,8 +138,9 @@ var createTestServer = async (options) => {
|
|
|
137
138
|
bootLogging: bootLogging ?? false,
|
|
138
139
|
port: 0
|
|
139
140
|
});
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
const settings = app.get(HttpOptionsProvider);
|
|
142
|
+
if (http.middleware === undefined && settings.middleware.length === 0)
|
|
143
|
+
warnAboutGlobals(app, collectModules(root), ("onError" in http ? http.onError : settings.onError) === undefined);
|
|
142
144
|
if (prefix !== undefined)
|
|
143
145
|
app.setGlobalPrefix(prefix);
|
|
144
146
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dunx/testing",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
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": "^3.1.
|
|
55
|
-
"@dunx/http": "^3.1.
|
|
54
|
+
"@dunx/core": "^3.1.2",
|
|
55
|
+
"@dunx/http": "^3.1.2",
|
|
56
56
|
"@types/bun": ">=1.3.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|