@noodleseed/one 0.22.0 → 0.23.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/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +2 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-dispatch.d.ts.map +1 -1
- package/dist/commands/catalog-dispatch.js +21 -2
- package/dist/commands/catalog-dispatch.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +28 -11
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/first-run.d.ts +11 -0
- package/dist/first-run.d.ts.map +1 -1
- package/dist/first-run.js +19 -4
- package/dist/first-run.js.map +1 -1
- package/dist/project-scaffold-templates.d.ts +11 -0
- package/dist/project-scaffold-templates.d.ts.map +1 -0
- package/dist/project-scaffold-templates.js +359 -0
- package/dist/project-scaffold-templates.js.map +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -323
- package/dist/project.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -0
- package/dist/validate.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/package.json +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +9 -10
- package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
- package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
- package/node_modules/tailwindcss/dist/lib.js +13 -13
- package/node_modules/tailwindcss/dist/lib.mjs +18 -18
- package/node_modules/tailwindcss/package.json +2 -2
- package/node_modules/undici/README.md +3 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +365 -178
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +779 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +47 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +1 -1
- package/node_modules/undici/lib/core/util.js +24 -1
- package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
- package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
- package/node_modules/undici/lib/handler/retry-handler.js +57 -19
- package/node_modules/undici/lib/util/cache.js +8 -2
- package/node_modules/undici/lib/web/cookies/parse.js +20 -27
- package/node_modules/undici/lib/web/cookies/util.js +1 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
- package/node_modules/undici/lib/web/eventsource/util.js +32 -1
- package/node_modules/undici/lib/web/fetch/body.js +43 -0
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +11 -2
- package/node_modules/undici/lib/web/fetch/request.js +1 -0
- package/node_modules/undici/lib/web/fetch/util.js +4 -1
- package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
- package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +6 -1
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/fetch.d.ts +1 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/package.json +4 -4
- package/react/styles.css +510 -5
- package/react/styles.source.css +850 -0
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
|
@@ -1,197 +1,371 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MockCallHistory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!--introduced_in=v7.5.0-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/mock/mock-call-history.js -->
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
const mockAgent = new MockAgent({ enableCallHistory: true })
|
|
7
|
-
mockAgent.getCallHistory()
|
|
7
|
+
> Stability: 2 - Stable
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
A `MockCallHistory` records the configuration of every request intercepted by a
|
|
10
|
+
[`MockAgent`][] for which call history is enabled. Each recorded request is
|
|
11
|
+
stored as a [`MockCallHistoryLog`][], and the `MockCallHistory` exposes helpers
|
|
12
|
+
to read and filter those logs in tests.
|
|
13
|
+
|
|
14
|
+
Instances are not created directly. Enable call history on a [`MockAgent`][] and
|
|
15
|
+
retrieve the history with `mockAgent.getCallHistory()`:
|
|
13
16
|
|
|
17
|
+
```mjs
|
|
18
|
+
import { MockAgent } from 'undici'
|
|
19
|
+
|
|
20
|
+
const mockAgent = new MockAgent({ enableCallHistory: true })
|
|
21
|
+
const callHistory = mockAgent.getCallHistory()
|
|
14
22
|
```
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
Call history can also be enabled after construction:
|
|
17
25
|
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
//...
|
|
21
|
-
}
|
|
26
|
+
```mjs
|
|
27
|
+
import { MockAgent } from 'undici'
|
|
22
28
|
|
|
23
|
-
const
|
|
24
|
-
|
|
29
|
+
const mockAgent = new MockAgent()
|
|
30
|
+
mockAgent.enableCallHistory()
|
|
31
|
+
const callHistory = mockAgent.getCallHistory()
|
|
25
32
|
```
|
|
26
33
|
|
|
27
|
-
##
|
|
34
|
+
## Class: `MockCallHistory`
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
<!-- YAML
|
|
37
|
+
added: v7.5.0
|
|
38
|
+
-->
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
Tracks the configuration of intercepted requests as an ordered collection of
|
|
41
|
+
[`MockCallHistoryLog`][] entries.
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
A `MockCallHistory` is iterable. Use it with a `for...of` loop, the spread
|
|
44
|
+
operator, or any constructor that accepts an iterable:
|
|
45
|
+
|
|
46
|
+
```mjs
|
|
47
|
+
for (const log of mockAgent.getCallHistory()) {
|
|
48
|
+
// ...
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const logs = [...mockAgent.getCallHistory()]
|
|
52
|
+
const logSet = new Set(mockAgent.getCallHistory())
|
|
37
53
|
```
|
|
38
54
|
|
|
39
|
-
### calls
|
|
55
|
+
### `mockCallHistory.calls()`
|
|
40
56
|
|
|
41
|
-
|
|
57
|
+
<!-- YAML
|
|
58
|
+
added: v7.5.0
|
|
59
|
+
-->
|
|
42
60
|
|
|
43
|
-
|
|
61
|
+
* Returns: {MockCallHistoryLog[]} All recorded logs, in the order the requests
|
|
62
|
+
were intercepted.
|
|
63
|
+
|
|
64
|
+
Returns every recorded [`MockCallHistoryLog`][] as an array.
|
|
65
|
+
|
|
66
|
+
```mjs
|
|
44
67
|
mockAgent.getCallHistory()?.calls()
|
|
45
68
|
```
|
|
46
69
|
|
|
47
|
-
### firstCall
|
|
70
|
+
### `mockCallHistory.firstCall()`
|
|
71
|
+
|
|
72
|
+
<!-- YAML
|
|
73
|
+
added: v7.5.0
|
|
74
|
+
-->
|
|
48
75
|
|
|
49
|
-
|
|
76
|
+
* Returns: {MockCallHistoryLog|undefined} The first recorded log, or `undefined`
|
|
77
|
+
when no request has been recorded.
|
|
50
78
|
|
|
51
|
-
|
|
79
|
+
Returns the first recorded [`MockCallHistoryLog`][].
|
|
80
|
+
|
|
81
|
+
```mjs
|
|
52
82
|
mockAgent.getCallHistory()?.firstCall()
|
|
53
83
|
```
|
|
54
84
|
|
|
55
|
-
### lastCall
|
|
85
|
+
### `mockCallHistory.lastCall()`
|
|
86
|
+
|
|
87
|
+
<!-- YAML
|
|
88
|
+
added: v7.5.0
|
|
89
|
+
-->
|
|
90
|
+
|
|
91
|
+
* Returns: {MockCallHistoryLog|undefined} The last recorded log, or `undefined`
|
|
92
|
+
when no request has been recorded.
|
|
56
93
|
|
|
57
|
-
|
|
94
|
+
Returns the last recorded [`MockCallHistoryLog`][].
|
|
58
95
|
|
|
59
|
-
```
|
|
96
|
+
```mjs
|
|
60
97
|
mockAgent.getCallHistory()?.lastCall()
|
|
61
98
|
```
|
|
62
99
|
|
|
63
|
-
### nthCall
|
|
100
|
+
### `mockCallHistory.nthCall(position)`
|
|
101
|
+
|
|
102
|
+
<!-- YAML
|
|
103
|
+
added: v7.5.0
|
|
104
|
+
-->
|
|
105
|
+
|
|
106
|
+
* `position` {number} The 1-based position of the log to return. Must be a
|
|
107
|
+
positive integer.
|
|
108
|
+
* Returns: {MockCallHistoryLog|undefined} The log at `position`, or `undefined`
|
|
109
|
+
when no log exists at that position.
|
|
64
110
|
|
|
65
|
-
|
|
111
|
+
Returns the [`MockCallHistoryLog`][] at the given 1-based `position`. The index
|
|
112
|
+
is 1-based for readability, so `nthCall(1)` is equivalent to `firstCall()`.
|
|
66
113
|
|
|
67
|
-
|
|
68
|
-
|
|
114
|
+
Throws an [`InvalidArgumentError`][] when `position` is not a number, not an
|
|
115
|
+
integer, or not positive. Use `firstCall()` or `lastCall()` instead of passing a
|
|
116
|
+
non-positive value.
|
|
117
|
+
|
|
118
|
+
```mjs
|
|
119
|
+
mockAgent.getCallHistory()?.nthCall(3) // the third recorded log
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `mockCallHistory.filterCalls(criteria[, options])`
|
|
123
|
+
|
|
124
|
+
<!-- YAML
|
|
125
|
+
added: v7.5.0
|
|
126
|
+
-->
|
|
127
|
+
|
|
128
|
+
* `criteria` {Function|RegExp|Object} The filter to apply.
|
|
129
|
+
* When a {Function} is given, it is used as the predicate of
|
|
130
|
+
`Array.prototype.filter` and receives each [`MockCallHistoryLog`][]; logs for
|
|
131
|
+
which it returns a truthy value are kept.
|
|
132
|
+
* When a {RegExp} is given, a log is kept when the expression matches its
|
|
133
|
+
[`mockCallHistoryLog.toString()`][] representation.
|
|
134
|
+
* When an {Object} is given, each property is a request field to filter on and
|
|
135
|
+
each value is a [filter parameter](#filter-parameter). An empty object
|
|
136
|
+
returns every log.
|
|
137
|
+
* `protocol` {string|RegExp|null|undefined} Filters by request protocol.
|
|
138
|
+
* `host` {string|RegExp|null|undefined} Filters by request host.
|
|
139
|
+
* `port` {string|RegExp|null|undefined} Filters by request port.
|
|
140
|
+
* `origin` {string|RegExp|null|undefined} Filters by request origin.
|
|
141
|
+
* `path` {string|RegExp|null|undefined} Filters by request path.
|
|
142
|
+
* `hash` {string|RegExp|null|undefined} Filters by request hash.
|
|
143
|
+
* `fullUrl` {string|RegExp|null|undefined} Filters by request full URL.
|
|
144
|
+
* `method` {string|RegExp|null|undefined} Filters by request method.
|
|
145
|
+
* `options` {Object} Adjusts the filtering behavior. Only applied when `criteria`
|
|
146
|
+
is an object. (optional)
|
|
147
|
+
* `operator` {string} How to combine multiple object properties. `'OR'` keeps
|
|
148
|
+
a log matching any criterion; `'AND'` keeps a log matching every criterion.
|
|
149
|
+
The value is case-insensitive. **Default:** `'OR'`.
|
|
150
|
+
* Returns: {MockCallHistoryLog[]} The matching logs. Duplicates produced by an
|
|
151
|
+
`'OR'` combination are removed.
|
|
152
|
+
|
|
153
|
+
A convenience method for applying one or several filters at once. It is a more
|
|
154
|
+
expressive alternative to the per-field helpers below.
|
|
155
|
+
|
|
156
|
+
Throws an [`InvalidArgumentError`][] when `criteria` is not a function, regular
|
|
157
|
+
expression, or object, or when `options.operator` is neither `'OR'` nor `'AND'`.
|
|
158
|
+
|
|
159
|
+
```mjs
|
|
160
|
+
const callHistory = mockAgent.getCallHistory()
|
|
161
|
+
|
|
162
|
+
callHistory?.filterCalls((log) =>
|
|
163
|
+
log.hash === '#hash' && log.headers?.authorization !== undefined)
|
|
164
|
+
|
|
165
|
+
callHistory?.filterCalls(/"errors": "wrong body"/)
|
|
166
|
+
|
|
167
|
+
// Logs with a hash containing `my-hash` OR a path equal to `/endpoint`.
|
|
168
|
+
callHistory?.filterCalls({ hash: /my-hash/, path: '/endpoint' })
|
|
169
|
+
|
|
170
|
+
// Logs with a hash containing `my-hash` AND a path equal to `/endpoint`.
|
|
171
|
+
callHistory?.filterCalls(
|
|
172
|
+
{ hash: /my-hash/, path: '/endpoint' },
|
|
173
|
+
{ operator: 'AND' }
|
|
174
|
+
)
|
|
69
175
|
```
|
|
70
176
|
|
|
71
|
-
### filterCallsByProtocol
|
|
177
|
+
### `mockCallHistory.filterCallsByProtocol(criteria)`
|
|
72
178
|
|
|
73
|
-
|
|
179
|
+
<!-- YAML
|
|
180
|
+
added: v7.5.0
|
|
181
|
+
-->
|
|
74
182
|
|
|
75
|
-
|
|
183
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
184
|
+
[filter parameter](#filter-parameter).
|
|
185
|
+
* Returns: {MockCallHistoryLog[]} The logs whose protocol matches `criteria`.
|
|
76
186
|
|
|
77
|
-
|
|
187
|
+
Filters the recorded logs by request protocol.
|
|
188
|
+
|
|
189
|
+
```mjs
|
|
78
190
|
mockAgent.getCallHistory()?.filterCallsByProtocol(/https/)
|
|
79
191
|
mockAgent.getCallHistory()?.filterCallsByProtocol('https:')
|
|
80
192
|
```
|
|
81
193
|
|
|
82
|
-
### filterCallsByHost
|
|
194
|
+
### `mockCallHistory.filterCallsByHost(criteria)`
|
|
195
|
+
|
|
196
|
+
<!-- YAML
|
|
197
|
+
added: v7.5.0
|
|
198
|
+
-->
|
|
83
199
|
|
|
84
|
-
|
|
200
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
201
|
+
[filter parameter](#filter-parameter).
|
|
202
|
+
* Returns: {MockCallHistoryLog[]} The logs whose host matches `criteria`.
|
|
85
203
|
|
|
86
|
-
|
|
204
|
+
Filters the recorded logs by request host.
|
|
87
205
|
|
|
88
|
-
```
|
|
206
|
+
```mjs
|
|
89
207
|
mockAgent.getCallHistory()?.filterCallsByHost(/localhost/)
|
|
90
208
|
mockAgent.getCallHistory()?.filterCallsByHost('localhost:3000')
|
|
91
209
|
```
|
|
92
210
|
|
|
93
|
-
### filterCallsByPort
|
|
211
|
+
### `mockCallHistory.filterCallsByPort(criteria)`
|
|
212
|
+
|
|
213
|
+
<!-- YAML
|
|
214
|
+
added: v7.5.0
|
|
215
|
+
-->
|
|
94
216
|
|
|
95
|
-
|
|
217
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
218
|
+
[filter parameter](#filter-parameter).
|
|
219
|
+
* Returns: {MockCallHistoryLog[]} The logs whose port matches `criteria`.
|
|
96
220
|
|
|
97
|
-
|
|
221
|
+
Filters the recorded logs by request port.
|
|
98
222
|
|
|
99
|
-
```
|
|
223
|
+
```mjs
|
|
100
224
|
mockAgent.getCallHistory()?.filterCallsByPort(/3000/)
|
|
101
225
|
mockAgent.getCallHistory()?.filterCallsByPort('3000')
|
|
102
226
|
mockAgent.getCallHistory()?.filterCallsByPort('')
|
|
103
227
|
```
|
|
104
228
|
|
|
105
|
-
### filterCallsByOrigin
|
|
229
|
+
### `mockCallHistory.filterCallsByOrigin(criteria)`
|
|
106
230
|
|
|
107
|
-
|
|
231
|
+
<!-- YAML
|
|
232
|
+
added: v7.5.0
|
|
233
|
+
-->
|
|
108
234
|
|
|
109
|
-
|
|
235
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
236
|
+
[filter parameter](#filter-parameter).
|
|
237
|
+
* Returns: {MockCallHistoryLog[]} The logs whose origin matches `criteria`.
|
|
110
238
|
|
|
111
|
-
|
|
239
|
+
Filters the recorded logs by request origin.
|
|
240
|
+
|
|
241
|
+
```mjs
|
|
112
242
|
mockAgent.getCallHistory()?.filterCallsByOrigin(/http:\/\/localhost:3000/)
|
|
113
243
|
mockAgent.getCallHistory()?.filterCallsByOrigin('http://localhost:3000')
|
|
114
244
|
```
|
|
115
245
|
|
|
116
|
-
### filterCallsByPath
|
|
246
|
+
### `mockCallHistory.filterCallsByPath(criteria)`
|
|
247
|
+
|
|
248
|
+
<!-- YAML
|
|
249
|
+
added: v7.5.0
|
|
250
|
+
-->
|
|
117
251
|
|
|
118
|
-
|
|
252
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
253
|
+
[filter parameter](#filter-parameter).
|
|
254
|
+
* Returns: {MockCallHistoryLog[]} The logs whose path matches `criteria`.
|
|
119
255
|
|
|
120
|
-
|
|
256
|
+
Filters the recorded logs by request path.
|
|
121
257
|
|
|
122
|
-
```
|
|
258
|
+
```mjs
|
|
123
259
|
mockAgent.getCallHistory()?.filterCallsByPath(/api\/v1\/graphql/)
|
|
124
260
|
mockAgent.getCallHistory()?.filterCallsByPath('/api/v1/graphql')
|
|
125
261
|
```
|
|
126
262
|
|
|
127
|
-
### filterCallsByHash
|
|
263
|
+
### `mockCallHistory.filterCallsByHash(criteria)`
|
|
264
|
+
|
|
265
|
+
<!-- YAML
|
|
266
|
+
added: v7.5.0
|
|
267
|
+
-->
|
|
128
268
|
|
|
129
|
-
|
|
269
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
270
|
+
[filter parameter](#filter-parameter).
|
|
271
|
+
* Returns: {MockCallHistoryLog[]} The logs whose hash matches `criteria`.
|
|
130
272
|
|
|
131
|
-
|
|
273
|
+
Filters the recorded logs by request hash.
|
|
132
274
|
|
|
133
|
-
```
|
|
134
|
-
mockAgent.getCallHistory()?.
|
|
135
|
-
mockAgent.getCallHistory()?.
|
|
275
|
+
```mjs
|
|
276
|
+
mockAgent.getCallHistory()?.filterCallsByHash(/hash/)
|
|
277
|
+
mockAgent.getCallHistory()?.filterCallsByHash('#hash')
|
|
136
278
|
```
|
|
137
279
|
|
|
138
|
-
### filterCallsByFullUrl
|
|
280
|
+
### `mockCallHistory.filterCallsByFullUrl(criteria)`
|
|
139
281
|
|
|
140
|
-
|
|
282
|
+
<!-- YAML
|
|
283
|
+
added: v7.5.0
|
|
284
|
+
-->
|
|
141
285
|
|
|
142
|
-
|
|
286
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
287
|
+
[filter parameter](#filter-parameter).
|
|
288
|
+
* Returns: {MockCallHistoryLog[]} The logs whose full URL matches `criteria`.
|
|
143
289
|
|
|
144
|
-
|
|
290
|
+
Filters the recorded logs by request full URL. The full URL contains the
|
|
291
|
+
protocol, host, port, path, query parameters, and hash.
|
|
292
|
+
|
|
293
|
+
```mjs
|
|
145
294
|
mockAgent.getCallHistory()?.filterCallsByFullUrl(/https:\/\/localhost:3000\/\?query=value#hash/)
|
|
146
295
|
mockAgent.getCallHistory()?.filterCallsByFullUrl('https://localhost:3000/?query=value#hash')
|
|
147
296
|
```
|
|
148
297
|
|
|
149
|
-
### filterCallsByMethod
|
|
298
|
+
### `mockCallHistory.filterCallsByMethod(criteria)`
|
|
299
|
+
|
|
300
|
+
<!-- YAML
|
|
301
|
+
added: v7.5.0
|
|
302
|
+
-->
|
|
150
303
|
|
|
151
|
-
|
|
304
|
+
* `criteria` {string|RegExp|null|undefined} See
|
|
305
|
+
[filter parameter](#filter-parameter).
|
|
306
|
+
* Returns: {MockCallHistoryLog[]} The logs whose method matches `criteria`.
|
|
152
307
|
|
|
153
|
-
|
|
308
|
+
Filters the recorded logs by request method.
|
|
154
309
|
|
|
155
|
-
```
|
|
310
|
+
```mjs
|
|
156
311
|
mockAgent.getCallHistory()?.filterCallsByMethod(/POST/)
|
|
157
312
|
mockAgent.getCallHistory()?.filterCallsByMethod('POST')
|
|
158
313
|
```
|
|
159
314
|
|
|
160
|
-
###
|
|
315
|
+
### `mockCallHistory.clear()`
|
|
161
316
|
|
|
162
|
-
|
|
317
|
+
<!-- YAML
|
|
318
|
+
added: v7.5.0
|
|
319
|
+
-->
|
|
163
320
|
|
|
164
|
-
|
|
321
|
+
* Returns: {undefined}
|
|
165
322
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
- regexp : filter MockCallHistoryLog when the regexp does not match on MockCallHistoryLog.toString() ([see](/docs/docs/api/MockCallHistoryLog.md#to-string))
|
|
169
|
-
- object : an object with MockCallHistoryLog properties as keys to apply multiple filters. each values are a [filter parameter](/docs/docs/api/MockCallHistory.md#filter-parameter)
|
|
170
|
-
- options : the second parameter. an object.
|
|
171
|
-
- options.operator : `'AND'` or `'OR'` (default `'OR'`). Used only if criteria is an object. see below
|
|
323
|
+
Removes every recorded [`MockCallHistoryLog`][]. This is performed
|
|
324
|
+
automatically when `mockAgent.close()` is called.
|
|
172
325
|
|
|
173
|
-
```
|
|
174
|
-
mockAgent.
|
|
175
|
-
|
|
326
|
+
```mjs
|
|
327
|
+
mockAgent.clearCallHistory()
|
|
328
|
+
// Equivalent to:
|
|
329
|
+
mockAgent.getCallHistory()?.clear()
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### `mockCallHistory[Symbol.iterator]()`
|
|
333
|
+
|
|
334
|
+
<!-- YAML
|
|
335
|
+
added: v7.5.0
|
|
336
|
+
-->
|
|
337
|
+
|
|
338
|
+
* Returns: {Generator} A generator yielding each recorded
|
|
339
|
+
[`MockCallHistoryLog`][] in order.
|
|
176
340
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// - a path equal to /endpoint
|
|
181
|
-
mockAgent.getCallHistory()?.filterCalls({ hash: /my-hash/, path: '/endpoint' })
|
|
341
|
+
Makes a `MockCallHistory` iterable, yielding the same logs returned by
|
|
342
|
+
`calls()`. This enables `for...of` iteration, the spread operator, and
|
|
343
|
+
constructing other iterables from a history.
|
|
182
344
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
345
|
+
```mjs
|
|
346
|
+
const callHistory = mockAgent.getCallHistory()
|
|
347
|
+
|
|
348
|
+
for (const log of callHistory) {
|
|
349
|
+
console.log(log.method, log.fullUrl)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const logs = [...callHistory]
|
|
188
353
|
```
|
|
189
354
|
|
|
190
|
-
##
|
|
355
|
+
## Filter parameter
|
|
356
|
+
|
|
357
|
+
The per-field `filterCallsBy*` helpers and the object form of `filterCalls()`
|
|
358
|
+
accept a filter parameter that is matched against the corresponding field of each
|
|
359
|
+
[`MockCallHistoryLog`][]:
|
|
360
|
+
|
|
361
|
+
* A {string} keeps a log only when the field is strictly equal to the value.
|
|
362
|
+
* `null` keeps a log only when the field is strictly equal to `null`.
|
|
363
|
+
* `undefined` keeps a log only when the field is strictly equal to `undefined`.
|
|
364
|
+
* A {RegExp} keeps a log only when the expression matches the field.
|
|
191
365
|
|
|
192
|
-
|
|
366
|
+
Any other value throws an [`InvalidArgumentError`][].
|
|
193
367
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
368
|
+
[`InvalidArgumentError`]: Errors.md#class-invalidargumenterror
|
|
369
|
+
[`MockAgent`]: MockAgent.md#class-mockagent
|
|
370
|
+
[`MockCallHistoryLog`]: MockCallHistoryLog.md#class-mockcallhistorylog
|
|
371
|
+
[`mockCallHistoryLog.toString()`]: MockCallHistoryLog.md#mockcallhistorylogtostring
|