@griffin-app/griffin-ts 0.1.7 → 0.1.9
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/ASSERTIONS_QUICK_REF.md +14 -2
- package/README.md +103 -72
- package/dist/assertions.d.ts +94 -64
- package/dist/assertions.d.ts.map +1 -1
- package/dist/assertions.js +169 -102
- package/dist/assertions.js.map +1 -1
- package/dist/builder.d.ts +16 -16
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +11 -14
- package/dist/builder.js.map +1 -1
- package/dist/builder.test.d.ts +2 -0
- package/dist/builder.test.d.ts.map +1 -0
- package/dist/builder.test.js +607 -0
- package/dist/builder.test.js.map +1 -0
- package/dist/example.js +3 -3
- package/dist/example.js.map +1 -1
- package/dist/frequency.test.d.ts +2 -0
- package/dist/frequency.test.d.ts.map +1 -0
- package/dist/frequency.test.js +110 -0
- package/dist/frequency.test.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/schema-exports.d.ts +1 -1
- package/dist/schema-exports.d.ts.map +1 -1
- package/dist/schema-exports.js +2 -2
- package/dist/schema-exports.js.map +1 -1
- package/dist/schema.d.ts +419 -251
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +147 -111
- package/dist/schema.js.map +1 -1
- package/dist/secrets.d.ts +1 -15
- package/dist/secrets.d.ts.map +1 -1
- package/dist/secrets.js +0 -6
- package/dist/secrets.js.map +1 -1
- package/dist/secrets.test.d.ts +2 -0
- package/dist/secrets.test.d.ts.map +1 -0
- package/dist/secrets.test.js +242 -0
- package/dist/secrets.test.js.map +1 -0
- package/dist/sequential-builder.d.ts +8 -10
- package/dist/sequential-builder.d.ts.map +1 -1
- package/dist/sequential-builder.js +8 -5
- package/dist/sequential-builder.js.map +1 -1
- package/dist/sequential-builder.test.d.ts +2 -0
- package/dist/sequential-builder.test.d.ts.map +1 -0
- package/dist/sequential-builder.test.js +520 -0
- package/dist/sequential-builder.test.js.map +1 -0
- package/dist/type-exports.d.ts +1 -1
- package/dist/type-exports.d.ts.map +1 -1
- package/dist/variable.d.ts +1 -1
- package/dist/variable.test.d.ts +2 -0
- package/dist/variable.test.d.ts.map +1 -0
- package/dist/variable.test.js +254 -0
- package/dist/variable.test.js.map +1 -0
- package/package.json +1 -1
- package/src/assertions.ts +321 -119
- package/src/builder.test.ts +751 -0
- package/src/builder.ts +30 -34
- package/src/example.ts +3 -3
- package/src/frequency.test.ts +191 -0
- package/src/index.ts +15 -14
- package/src/schema-exports.ts +6 -7
- package/src/schema.ts +198 -132
- package/src/secrets.test.ts +299 -0
- package/src/secrets.ts +1 -17
- package/src/sequential-builder.test.ts +562 -0
- package/src/sequential-builder.ts +25 -27
- package/src/type-exports.ts +5 -6
- package/src/variable.test.ts +334 -0
- package/src/variable.ts +1 -1
- package/vitest.config.ts +14 -0
package/ASSERTIONS_QUICK_REF.md
CHANGED
|
@@ -8,13 +8,16 @@
|
|
|
8
8
|
])
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Accessors
|
|
11
|
+
## Accessors (Subjects)
|
|
12
12
|
|
|
13
13
|
| Accessor | Description | Example |
|
|
14
14
|
| ---------- | -------------------- | --------------------------------------- |
|
|
15
|
-
| `.body` | Response body
|
|
15
|
+
| `.body` | Response body | `state["node"].body["data"]["id"]` |
|
|
16
16
|
| `.headers` | Response headers | `state["node"].headers["content-type"]` |
|
|
17
17
|
| `.status` | HTTP status code | `state["node"].status` |
|
|
18
|
+
| `.latency` | Request latency (ms) | `state["node"].latency` |
|
|
19
|
+
|
|
20
|
+
**Note:** For body assertions, the response type is automatically detected and defaults to JSON. Path traversal uses JSONPath for JSON responses.
|
|
18
21
|
|
|
19
22
|
## Array Access
|
|
20
23
|
|
|
@@ -75,6 +78,14 @@ Assert(state["node"].status).lessThan(400); // Any success
|
|
|
75
78
|
Assert(state["node"].status).not.equals(500); // Not server error
|
|
76
79
|
```
|
|
77
80
|
|
|
81
|
+
### Latency Checks
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
Assert(state["node"].latency).lessThan(500); // Response time under 500ms
|
|
85
|
+
Assert(state["node"].latency).lessThanOrEqual(1000); // Max 1 second
|
|
86
|
+
Assert(state["node"].latency).greaterThan(0); // Sanity check
|
|
87
|
+
```
|
|
88
|
+
|
|
78
89
|
### Existence Checks
|
|
79
90
|
|
|
80
91
|
```typescript
|
|
@@ -151,6 +162,7 @@ TypeScript provides autocomplete and errors:
|
|
|
151
162
|
| Task | Code |
|
|
152
163
|
| ----------------- | -------------------------------------------------------- |
|
|
153
164
|
| Status is 200 | `Assert(state["n"].status).equals(200)` |
|
|
165
|
+
| Latency < 500ms | `Assert(state["n"].latency).lessThan(500)` |
|
|
154
166
|
| Body field exists | `Assert(state["n"].body["x"]).not.isNull()` |
|
|
155
167
|
| String contains | `Assert(state["n"].body["msg"]).contains("ok")` |
|
|
156
168
|
| Number in range | `Assert(state["n"].body["age"]).greaterThanOrEqual(18)` |
|
package/README.md
CHANGED
|
@@ -36,27 +36,27 @@ griffin provides two builder APIs:
|
|
|
36
36
|
The sequential builder automatically connects steps in order - no need to manage edges manually.
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import { GET, createTestBuilder, JSON, Frequency } from "griffin-ts";
|
|
39
|
+
import { GET, createTestBuilder, JSON, Frequency, Assert } from "griffin-ts";
|
|
40
40
|
|
|
41
41
|
const plan = createTestBuilder({
|
|
42
42
|
name: "health-check",
|
|
43
|
-
|
|
43
|
+
endpoint_host: "https://api.example.com",
|
|
44
44
|
})
|
|
45
|
-
.
|
|
45
|
+
.endpoint("health", {
|
|
46
46
|
method: GET,
|
|
47
47
|
response_format: JSON,
|
|
48
48
|
path: "/health",
|
|
49
49
|
})
|
|
50
|
-
.assert([
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
.assert((state) => [
|
|
51
|
+
Assert(state["health"].status).equals(200),
|
|
52
|
+
Assert(state["health"].body["status"]).equals("ok"),
|
|
53
53
|
])
|
|
54
|
-
.build();
|
|
54
|
+
.build({ frequency: Frequency.every(1).minute() });
|
|
55
55
|
|
|
56
56
|
export default plan;
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
#### Sequential Example with Waits
|
|
59
|
+
#### Sequential Example with Waits and Assertions
|
|
60
60
|
|
|
61
61
|
```typescript
|
|
62
62
|
import {
|
|
@@ -66,30 +66,35 @@ import {
|
|
|
66
66
|
JSON,
|
|
67
67
|
Frequency,
|
|
68
68
|
Wait,
|
|
69
|
+
Assert,
|
|
69
70
|
} from "griffin-ts";
|
|
70
71
|
|
|
71
72
|
const plan = createTestBuilder({
|
|
72
73
|
name: "create-and-verify-user",
|
|
73
|
-
|
|
74
|
+
endpoint_host: "https://api.example.com",
|
|
74
75
|
})
|
|
75
|
-
.
|
|
76
|
+
.endpoint("create_user", {
|
|
76
77
|
method: POST,
|
|
77
78
|
response_format: JSON,
|
|
78
79
|
path: "/api/v1/users",
|
|
79
80
|
body: { name: "Test User", email: "test@example.com" },
|
|
80
81
|
})
|
|
81
|
-
.assert(
|
|
82
|
+
.assert((state) => [
|
|
83
|
+
Assert(state["create_user"].status).equals(201),
|
|
84
|
+
Assert(state["create_user"].body["id"]).not.isNull(),
|
|
85
|
+
])
|
|
82
86
|
.wait(Wait.seconds(2))
|
|
83
|
-
.
|
|
87
|
+
.endpoint("get_user", {
|
|
84
88
|
method: GET,
|
|
85
89
|
response_format: JSON,
|
|
86
90
|
path: "/api/v1/users/test@example.com",
|
|
87
91
|
})
|
|
88
|
-
.assert([
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
.assert((state) => [
|
|
93
|
+
Assert(state["get_user"].status).equals(200),
|
|
94
|
+
Assert(state["get_user"].body["name"]).equals("Test User"),
|
|
95
|
+
Assert(state["get_user"].latency).lessThan(500),
|
|
91
96
|
])
|
|
92
|
-
.build();
|
|
97
|
+
.build({ frequency: Frequency.every(5).minute() });
|
|
93
98
|
|
|
94
99
|
export default plan;
|
|
95
100
|
```
|
|
@@ -103,45 +108,41 @@ import {
|
|
|
103
108
|
GET,
|
|
104
109
|
POST,
|
|
105
110
|
createGraphBuilder,
|
|
106
|
-
Endpoint,
|
|
107
|
-
Assertion,
|
|
108
|
-
WaitNode,
|
|
109
111
|
JSON,
|
|
110
112
|
START,
|
|
111
113
|
END,
|
|
112
114
|
Frequency,
|
|
113
115
|
Wait,
|
|
116
|
+
Assert,
|
|
114
117
|
} from "griffin-ts";
|
|
115
118
|
|
|
116
119
|
const plan = createGraphBuilder({
|
|
117
120
|
name: "foo-bar-check",
|
|
118
|
-
|
|
121
|
+
endpoint_host: "https://api.example.com",
|
|
119
122
|
})
|
|
120
|
-
.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
.addNode("wait_between", WaitNode(Wait.seconds(2)))
|
|
138
|
-
.addNode("check_status", Assertion([{ type: "status", expected: 200 }]))
|
|
123
|
+
.addHttpRequest("create_foo", {
|
|
124
|
+
method: POST,
|
|
125
|
+
response_format: JSON,
|
|
126
|
+
path: "/api/v1/foo",
|
|
127
|
+
body: { name: "test", value: 42 },
|
|
128
|
+
})
|
|
129
|
+
.addWait("wait_between", Wait.seconds(2))
|
|
130
|
+
.addHttpRequest("get_foo", {
|
|
131
|
+
method: GET,
|
|
132
|
+
response_format: JSON,
|
|
133
|
+
path: "/api/v1/foo/1",
|
|
134
|
+
})
|
|
135
|
+
.addAssertion("check_response", (state) => [
|
|
136
|
+
Assert(state["get_foo"].status).equals(200),
|
|
137
|
+
Assert(state["get_foo"].body["value"]).equals(42),
|
|
138
|
+
Assert(state["get_foo"].latency).lessThan(1000),
|
|
139
|
+
])
|
|
139
140
|
.addEdge(START, "create_foo")
|
|
140
141
|
.addEdge("create_foo", "wait_between")
|
|
141
142
|
.addEdge("wait_between", "get_foo")
|
|
142
|
-
.addEdge("get_foo", "
|
|
143
|
-
.addEdge("
|
|
144
|
-
.build();
|
|
143
|
+
.addEdge("get_foo", "check_response")
|
|
144
|
+
.addEdge("check_response", END)
|
|
145
|
+
.build({ frequency: Frequency.every(1).minute() });
|
|
145
146
|
|
|
146
147
|
export default plan;
|
|
147
148
|
```
|
|
@@ -153,13 +154,20 @@ griffin supports secure secret management for API keys, tokens, and other creden
|
|
|
153
154
|
#### With Sequential Builder
|
|
154
155
|
|
|
155
156
|
```typescript
|
|
156
|
-
import {
|
|
157
|
+
import {
|
|
158
|
+
GET,
|
|
159
|
+
createTestBuilder,
|
|
160
|
+
JSON,
|
|
161
|
+
Frequency,
|
|
162
|
+
secret,
|
|
163
|
+
Assert,
|
|
164
|
+
} from "griffin-ts";
|
|
157
165
|
|
|
158
166
|
const plan = createTestBuilder({
|
|
159
167
|
name: "authenticated-check",
|
|
160
|
-
|
|
168
|
+
endpoint_host: "https://api.example.com",
|
|
161
169
|
})
|
|
162
|
-
.
|
|
170
|
+
.endpoint("protected", {
|
|
163
171
|
method: GET,
|
|
164
172
|
response_format: JSON,
|
|
165
173
|
path: "/api/protected",
|
|
@@ -176,8 +184,8 @@ const plan = createTestBuilder({
|
|
|
176
184
|
apiKey: secret("env:API_KEY"),
|
|
177
185
|
},
|
|
178
186
|
})
|
|
179
|
-
.assert(
|
|
180
|
-
.build();
|
|
187
|
+
.assert((state) => [Assert(state["protected"].status).equals(200)])
|
|
188
|
+
.build({ frequency: Frequency.every(5).minute() });
|
|
181
189
|
|
|
182
190
|
export default plan;
|
|
183
191
|
```
|
|
@@ -188,36 +196,34 @@ export default plan;
|
|
|
188
196
|
import {
|
|
189
197
|
GET,
|
|
190
198
|
createGraphBuilder,
|
|
191
|
-
Endpoint,
|
|
192
|
-
Assertion,
|
|
193
199
|
JSON,
|
|
194
200
|
START,
|
|
195
201
|
END,
|
|
196
202
|
Frequency,
|
|
197
203
|
secret,
|
|
204
|
+
Assert,
|
|
198
205
|
} from "griffin-ts";
|
|
199
206
|
|
|
200
207
|
const plan = createGraphBuilder({
|
|
201
208
|
name: "authenticated-check",
|
|
202
|
-
|
|
209
|
+
endpoint_host: "https://api.example.com",
|
|
203
210
|
})
|
|
204
|
-
.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)
|
|
216
|
-
.addNode("verify", Assertion([{ type: "status", expected: 200 }]))
|
|
211
|
+
.addHttpRequest("authenticated_request", {
|
|
212
|
+
method: GET,
|
|
213
|
+
response_format: JSON,
|
|
214
|
+
path: "/api/protected",
|
|
215
|
+
headers: {
|
|
216
|
+
"X-API-Key": secret("env:API_KEY"),
|
|
217
|
+
Authorization: secret("aws:prod/api-token"),
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
.addAssertion("verify", (state) => [
|
|
221
|
+
Assert(state["authenticated_request"].status).equals(200),
|
|
222
|
+
])
|
|
217
223
|
.addEdge(START, "authenticated_request")
|
|
218
224
|
.addEdge("authenticated_request", "verify")
|
|
219
225
|
.addEdge("verify", END)
|
|
220
|
-
.build();
|
|
226
|
+
.build({ frequency: Frequency.every(5).minute() });
|
|
221
227
|
|
|
222
228
|
export default plan;
|
|
223
229
|
```
|
|
@@ -252,22 +258,47 @@ See the [griffin-runner CONFIG.md](../griffin-runner/CONFIG.md) for configuratio
|
|
|
252
258
|
|
|
253
259
|
#### Sequential Builder Methods
|
|
254
260
|
|
|
255
|
-
- **`.
|
|
256
|
-
- **`.wait(duration)`**: Add a delay (use `Wait.seconds(n)` or `Wait.
|
|
257
|
-
- **`.assert(
|
|
258
|
-
- **`.build()`**: Generate the final test plan
|
|
261
|
+
- **`.endpoint(id, config)`**: Add an HTTP endpoint request with a unique identifier
|
|
262
|
+
- **`.wait(duration)`**: Add a delay (use `Wait.seconds(n)`, `Wait.minutes(n)`, or `Wait.milliseconds(n)`)
|
|
263
|
+
- **`.assert(fn)`**: Add assertions using a function that receives the state proxy and returns an array of assertions
|
|
264
|
+
- **`.build(options)`**: Generate the final test plan with frequency configuration
|
|
259
265
|
|
|
260
266
|
#### Graph Builder Methods
|
|
261
267
|
|
|
262
|
-
- **`.
|
|
268
|
+
- **`.addHttpRequest(id, config)`**: Add an endpoint node to the graph
|
|
269
|
+
- **`.addWait(id, duration)`**: Add a wait node to the graph
|
|
270
|
+
- **`.addAssertion(id, fn)`**: Add an assertion node using a function that receives the state proxy
|
|
263
271
|
- **`.addEdge(from, to)`**: Connect two nodes (use `START` and `END` constants for entry/exit)
|
|
264
|
-
- **`.build()`**: Generate the final test plan (validates all nodes are connected)
|
|
272
|
+
- **`.build(options)`**: Generate the final test plan (validates all nodes are connected)
|
|
273
|
+
|
|
274
|
+
#### Assertions
|
|
275
|
+
|
|
276
|
+
Use the `Assert()` function with the state proxy to create type-safe assertions:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
.assert((state) => [
|
|
280
|
+
// Status checks
|
|
281
|
+
Assert(state["node"].status).equals(200),
|
|
282
|
+
|
|
283
|
+
// Latency checks
|
|
284
|
+
Assert(state["node"].latency).lessThan(500),
|
|
285
|
+
|
|
286
|
+
// Body assertions (JSONPath automatically detected)
|
|
287
|
+
Assert(state["node"].body["id"]).not.isNull(),
|
|
288
|
+
Assert(state["node"].body["name"]).equals("test"),
|
|
289
|
+
|
|
290
|
+
// Header assertions
|
|
291
|
+
Assert(state["node"].headers["content-type"]).contains("json"),
|
|
292
|
+
])
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
See [ASSERTIONS_QUICK_REF.md](./ASSERTIONS_QUICK_REF.md) for the complete assertion API.
|
|
265
296
|
|
|
266
297
|
#### General
|
|
267
298
|
|
|
268
|
-
- **Frequency**: Use `Frequency.every(n).minute()`, `.hour()`, or `.day()`
|
|
299
|
+
- **Frequency**: Use `Frequency.every(n).minute()`, `.hour()`, or `.day()` in the `build()` options
|
|
269
300
|
- **Secrets**: Use `secret("provider:path")` to reference secrets that are resolved at runtime
|
|
270
|
-
- **
|
|
301
|
+
- **Response Types**: JSON (default), XML, and TEXT response formats are supported
|
|
271
302
|
|
|
272
303
|
## Output
|
|
273
304
|
|
package/dist/assertions.d.ts
CHANGED
|
@@ -6,82 +6,107 @@
|
|
|
6
6
|
* - Assert: Builder for creating assertions with fluent API
|
|
7
7
|
* - Support for unary and binary predicates with negation
|
|
8
8
|
*/
|
|
9
|
+
import { type Assertion, AssertionSubject, ResponseFormat } from "./schema.js";
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Descriptor for body assertions - supports nested JSONPath access
|
|
11
12
|
*/
|
|
12
|
-
export interface
|
|
13
|
+
export interface BodyDescriptor {
|
|
13
14
|
nodeId: string;
|
|
14
|
-
|
|
15
|
+
subject: AssertionSubject.BODY;
|
|
15
16
|
path: string[];
|
|
17
|
+
responseType: ResponseFormat;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
20
|
+
* Descriptor for header assertions - single header name, no nesting
|
|
19
21
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
IS_FALSE = "IS_FALSE",
|
|
25
|
-
IS_EMPTY = "IS_EMPTY",
|
|
26
|
-
IS_NOT_EMPTY = "IS_NOT_EMPTY"
|
|
22
|
+
export interface HeaderDescriptor {
|
|
23
|
+
nodeId: string;
|
|
24
|
+
subject: AssertionSubject.HEADERS;
|
|
25
|
+
headerName: string;
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
NOT_STARTS_WITH = "NOT_STARTS_WITH",
|
|
42
|
-
ENDS_WITH = "ENDS_WITH",
|
|
43
|
-
NOT_ENDS_WITH = "NOT_ENDS_WITH"
|
|
28
|
+
* Descriptor for status assertions - no path needed
|
|
29
|
+
*/
|
|
30
|
+
export interface StatusDescriptor {
|
|
31
|
+
nodeId: string;
|
|
32
|
+
subject: AssertionSubject.STATUS;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Descriptor for latency assertions - no path needed
|
|
36
|
+
*/
|
|
37
|
+
export interface LatencyDescriptor {
|
|
38
|
+
nodeId: string;
|
|
39
|
+
subject: AssertionSubject.LATENCY;
|
|
44
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Union of all assertion descriptors
|
|
43
|
+
*/
|
|
44
|
+
export type AssertionDescriptor = BodyDescriptor | HeaderDescriptor | StatusDescriptor | LatencyDescriptor;
|
|
45
45
|
/**
|
|
46
46
|
* Binary predicate with operator and expected value
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Symbol used to store descriptor metadata in proxy objects
|
|
50
|
+
*/
|
|
51
|
+
declare const DESCRIPTOR_SYMBOL: unique symbol;
|
|
52
|
+
/**
|
|
53
|
+
* Internal interface for proxy objects that carry a body descriptor
|
|
54
|
+
*/
|
|
55
|
+
interface ProxyWithBodyDescriptor {
|
|
56
|
+
[DESCRIPTOR_SYMBOL]: BodyDescriptor;
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
|
-
*
|
|
59
|
+
* Internal interface for proxy objects that carry a header descriptor
|
|
54
60
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
accessor: "body" | "headers" | "status";
|
|
58
|
-
path: string[];
|
|
59
|
-
predicate: UnaryPredicate | BinaryPredicate;
|
|
61
|
+
interface ProxyWithHeaderDescriptor {
|
|
62
|
+
[DESCRIPTOR_SYMBOL]: HeaderDescriptor;
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
|
-
*
|
|
65
|
+
* Internal interface for proxy objects that carry a status descriptor
|
|
63
66
|
*/
|
|
64
|
-
|
|
67
|
+
interface ProxyWithStatusDescriptor {
|
|
68
|
+
[DESCRIPTOR_SYMBOL]: StatusDescriptor;
|
|
69
|
+
}
|
|
65
70
|
/**
|
|
66
|
-
* Internal interface for proxy objects that carry
|
|
71
|
+
* Internal interface for proxy objects that carry a latency descriptor
|
|
67
72
|
*/
|
|
68
|
-
interface
|
|
69
|
-
[
|
|
73
|
+
interface ProxyWithLatencyDescriptor {
|
|
74
|
+
[DESCRIPTOR_SYMBOL]: LatencyDescriptor;
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
|
-
* Proxy for accessing nested properties within a
|
|
73
|
-
*
|
|
77
|
+
* Proxy for accessing nested properties within a body.
|
|
78
|
+
* Supports arbitrary depth: body["data"]["users"][0]["name"]
|
|
79
|
+
*/
|
|
80
|
+
export type BodyProxy = ProxyWithBodyDescriptor & {
|
|
81
|
+
[key: string]: BodyProxy;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Terminal proxy for a single header value. No further nesting allowed.
|
|
85
|
+
*/
|
|
86
|
+
export type HeaderValueProxy = ProxyWithHeaderDescriptor;
|
|
87
|
+
/**
|
|
88
|
+
* Proxy for accessing header values. Only allows one level of access.
|
|
89
|
+
* e.g., headers["content-type"] returns a HeaderValueProxy
|
|
74
90
|
*/
|
|
75
|
-
export type
|
|
76
|
-
[key: string]:
|
|
91
|
+
export type HeadersProxy = {
|
|
92
|
+
[key: string]: HeaderValueProxy;
|
|
77
93
|
};
|
|
78
94
|
/**
|
|
79
|
-
*
|
|
95
|
+
* Terminal proxy for status. No further nesting allowed.
|
|
96
|
+
*/
|
|
97
|
+
export type StatusProxy = ProxyWithStatusDescriptor;
|
|
98
|
+
/**
|
|
99
|
+
* Terminal proxy for latency. No further nesting allowed.
|
|
100
|
+
*/
|
|
101
|
+
export type LatencyProxy = ProxyWithLatencyDescriptor;
|
|
102
|
+
/**
|
|
103
|
+
* Proxy for a node result with body, headers, status, and latency accessors
|
|
80
104
|
*/
|
|
81
105
|
export type NodeResultProxy = {
|
|
82
|
-
body:
|
|
83
|
-
headers:
|
|
84
|
-
status:
|
|
106
|
+
body: BodyProxy;
|
|
107
|
+
headers: HeadersProxy;
|
|
108
|
+
status: StatusProxy;
|
|
109
|
+
latency: LatencyProxy;
|
|
85
110
|
};
|
|
86
111
|
/**
|
|
87
112
|
* State proxy that maps node names to their result proxies
|
|
@@ -96,7 +121,7 @@ export declare function createStateProxy<NodeNames extends string>(nodeNames: No
|
|
|
96
121
|
export declare class AssertBuilder {
|
|
97
122
|
private descriptor;
|
|
98
123
|
private negated;
|
|
99
|
-
constructor(descriptor:
|
|
124
|
+
constructor(descriptor: AssertionDescriptor);
|
|
100
125
|
/**
|
|
101
126
|
* Negation modifier - flips the meaning of the subsequent predicate
|
|
102
127
|
*
|
|
@@ -105,21 +130,26 @@ export declare class AssertBuilder {
|
|
|
105
130
|
* Assert(state["node"].body["name"]).not.equals("") // NOT_EQUAL
|
|
106
131
|
*/
|
|
107
132
|
get not(): this;
|
|
108
|
-
isNull():
|
|
109
|
-
isDefined():
|
|
110
|
-
isTrue():
|
|
111
|
-
isFalse():
|
|
112
|
-
isEmpty():
|
|
113
|
-
equals(expected: unknown):
|
|
114
|
-
greaterThan(expected: number):
|
|
115
|
-
lessThan(expected: number):
|
|
116
|
-
greaterThanOrEqual(expected: number):
|
|
117
|
-
lessThanOrEqual(expected: number):
|
|
118
|
-
contains(expected: string):
|
|
119
|
-
startsWith(expected: string):
|
|
120
|
-
endsWith(expected: string):
|
|
121
|
-
private
|
|
133
|
+
isNull(): Assertion;
|
|
134
|
+
isDefined(): Assertion;
|
|
135
|
+
isTrue(): Assertion;
|
|
136
|
+
isFalse(): Assertion;
|
|
137
|
+
isEmpty(): Assertion;
|
|
138
|
+
equals(expected: unknown): Assertion;
|
|
139
|
+
greaterThan(expected: number): Assertion;
|
|
140
|
+
lessThan(expected: number): Assertion;
|
|
141
|
+
greaterThanOrEqual(expected: number): Assertion;
|
|
142
|
+
lessThanOrEqual(expected: number): Assertion;
|
|
143
|
+
contains(expected: string): Assertion;
|
|
144
|
+
startsWith(expected: string): Assertion;
|
|
145
|
+
endsWith(expected: string): Assertion;
|
|
146
|
+
private createUnaryAssertion;
|
|
147
|
+
private createBinaryAssertion;
|
|
122
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Union of all assertable proxy types
|
|
151
|
+
*/
|
|
152
|
+
export type AssertableProxy = BodyProxy | HeaderValueProxy | StatusProxy | LatencyProxy;
|
|
123
153
|
/**
|
|
124
154
|
* Creates an assertion builder from a state proxy reference
|
|
125
155
|
*
|
|
@@ -131,6 +161,6 @@ export declare class AssertBuilder {
|
|
|
131
161
|
* Assert(state["create_user"].status).equals(201)
|
|
132
162
|
* Assert(state["create_user"].headers["content-type"]).contains("application/json")
|
|
133
163
|
*/
|
|
134
|
-
export declare function Assert(proxyRef:
|
|
164
|
+
export declare function Assert(proxyRef: AssertableProxy): AssertBuilder;
|
|
135
165
|
export {};
|
|
136
166
|
//# sourceMappingURL=assertions.d.ts.map
|
package/dist/assertions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,SAAS,EACd,gBAAgB,EAEhB,cAAc,EAGf,MAAM,aAAa,CAAC;AAQrB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,EAAE,cAAc,CAAC;CAC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