@noego/testing 0.6.0 → 0.7.1
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 +100 -0
- package/dist/browser/index.cjs +460 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +61 -0
- package/dist/browser/index.d.ts +61 -0
- package/dist/browser/index.js +291 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/setup.cjs +90 -0
- package/dist/browser/setup.cjs.map +1 -0
- package/dist/browser/setup.d.cts +8 -0
- package/dist/browser/setup.d.ts +8 -0
- package/dist/browser/setup.js +14 -0
- package/dist/browser/setup.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-P26IJDOI.js +99 -0
- package/dist/chunk-P26IJDOI.js.map +1 -0
- package/dist/chunk-YX44DAOH.js +38 -0
- package/dist/chunk-YX44DAOH.js.map +1 -0
- package/dist/fetch/index.cjs +279 -0
- package/dist/fetch/index.cjs.map +1 -0
- package/dist/fetch/index.d.cts +6 -0
- package/dist/fetch/index.d.ts +6 -0
- package/dist/fetch/index.js +219 -0
- package/dist/fetch/index.js.map +1 -0
- package/dist/index.cjs +791 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +264 -2
- package/dist/index.d.ts +264 -2
- package/dist/index.js +772 -73
- package/dist/index.js.map +1 -1
- package/dist/runtime-CdrMRuv2.d.cts +61 -0
- package/dist/runtime-CdrMRuv2.d.ts +61 -0
- package/package.json +35 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Express-like convenience; terminal methods create ordinary Web Responses. */
|
|
2
|
+
declare class FetchRouteResponse {
|
|
3
|
+
private code;
|
|
4
|
+
private readonly responseHeaders;
|
|
5
|
+
private completed;
|
|
6
|
+
status(code: number): this;
|
|
7
|
+
header(name: string, value: string): this;
|
|
8
|
+
headers(values: HeadersInit): this;
|
|
9
|
+
append(name: string, value: string): this;
|
|
10
|
+
json(value: unknown): Response;
|
|
11
|
+
text(value: string): Response;
|
|
12
|
+
html(value: string): Response;
|
|
13
|
+
end(): Response;
|
|
14
|
+
redirect(url: string, status?: number): Response;
|
|
15
|
+
/** @internal Allows Express-style handlers to omit `return res.json(...)`. */
|
|
16
|
+
result(): Response | undefined;
|
|
17
|
+
private finish;
|
|
18
|
+
private assertWritable;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type FetchRouteRequest = Request & {
|
|
22
|
+
readonly params: Readonly<Record<string, string>>;
|
|
23
|
+
readonly query: Readonly<Record<string, string | readonly string[]>>;
|
|
24
|
+
};
|
|
25
|
+
type FetchRouteHandler = (request: FetchRouteRequest, response: FetchRouteResponse) => Response | void | Promise<Response | void>;
|
|
26
|
+
interface FetchRouteDefinition {
|
|
27
|
+
readonly method: string;
|
|
28
|
+
readonly pattern: string;
|
|
29
|
+
readonly handler: FetchRouteHandler;
|
|
30
|
+
readonly match: (url: URL) => Record<string, string> | null;
|
|
31
|
+
}
|
|
32
|
+
interface FetchRoutes {
|
|
33
|
+
get(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
34
|
+
post(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
35
|
+
put(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
36
|
+
patch(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
37
|
+
delete(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
38
|
+
head(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
39
|
+
options(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
40
|
+
all(pattern: string, handler: FetchRouteHandler): FetchRoutes;
|
|
41
|
+
}
|
|
42
|
+
type ConfigureFetch = (app: FetchRoutes) => void;
|
|
43
|
+
/** Snapshot routes at declaration time, just like the immutable test builders. */
|
|
44
|
+
declare function defineFetchRoutes(configure: ConfigureFetch): readonly FetchRouteDefinition[];
|
|
45
|
+
|
|
46
|
+
interface TestFetchRuntime {
|
|
47
|
+
/** Matched route only, one response, no redirects. null = use the caller's native network. */
|
|
48
|
+
dispatch(request: Request): Promise<Response | null>;
|
|
49
|
+
readonly fetch: typeof globalThis.fetch;
|
|
50
|
+
settle(): Promise<void>;
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
/** Preserve native Request/Response/body/header/signal semantics at the boundary. */
|
|
54
|
+
declare function normalizeFetchRequest(input: RequestInfo | URL, init?: RequestInit, origin?: string): Request;
|
|
55
|
+
/** A build owns its cancellation/pending work. Route definitions contain no run state. */
|
|
56
|
+
declare function createTestFetch(routes: readonly FetchRouteDefinition[], options?: {
|
|
57
|
+
origin?: string;
|
|
58
|
+
fallback?: typeof globalThis.fetch;
|
|
59
|
+
}): TestFetchRuntime;
|
|
60
|
+
|
|
61
|
+
export { type ConfigureFetch as C, type FetchRouteDefinition as F, type TestFetchRuntime as T, type FetchRouteHandler as a, type FetchRouteRequest as b, FetchRouteResponse as c, type FetchRoutes as d, createTestFetch as e, defineFetchRoutes as f, normalizeFetchRequest as n };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noego/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Canonical NoEgo shared testing owner: testIoc real-IoC composition and the lowercase test.* method behavior/watch/expectation language",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,7 +19,21 @@
|
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
-
"./package.json": "./package.json"
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
"./fetch": {
|
|
24
|
+
"types": "./dist/fetch/index.d.ts",
|
|
25
|
+
"import": "./dist/fetch/index.js",
|
|
26
|
+
"require": "./dist/fetch/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./browser-test-setup": {
|
|
29
|
+
"types": "./dist/browser/setup.d.ts",
|
|
30
|
+
"import": "./dist/browser/setup.js"
|
|
31
|
+
},
|
|
32
|
+
"./browser": {
|
|
33
|
+
"types": "./dist/browser/index.d.ts",
|
|
34
|
+
"import": "./dist/browser/index.js",
|
|
35
|
+
"require": "./dist/browser/index.cjs"
|
|
36
|
+
}
|
|
23
37
|
},
|
|
24
38
|
"files": [
|
|
25
39
|
"dist",
|
|
@@ -42,6 +56,24 @@
|
|
|
42
56
|
"typescript": "^5.8.3"
|
|
43
57
|
},
|
|
44
58
|
"peerDependencies": {
|
|
45
|
-
"@noego/ioc": ">=0.8.0"
|
|
59
|
+
"@noego/ioc": ">=0.8.0",
|
|
60
|
+
"playwright": ">=1.62.0",
|
|
61
|
+
"happy-dom": ">=20.0.0",
|
|
62
|
+
"vite": ">=5.0.0",
|
|
63
|
+
"@sveltejs/vite-plugin-svelte": ">=3.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"playwright": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"happy-dom": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"vite": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@sveltejs/vite-plugin-svelte": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
46
78
|
}
|
|
47
79
|
}
|