quidproquo-testing 0.1.16 → 0.1.18
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 +42 -7
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
# quidproquo
|
|
1
|
+
# quidproquo-testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Test helpers for [quidproquo](https://github.com/qpqjs/quidproquo) generators.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A qpq story is a generator that yields actions, which means you can test it by stepping through what it yields rather than by standing up infrastructure. This package gives you a fluent way to assert on that sequence, plus matchers that make the failures readable in vitest.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev quidproquo-testing
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
`vitest` is a peer dependency.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## `expectGenerator`
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Walk a story action by action, supplying the result of each one:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { expectGenerator } from 'quidproquo-testing';
|
|
19
|
+
|
|
20
|
+
expectGenerator(askGreet('world'))
|
|
21
|
+
.toYield({ type: DateActionType.Now })
|
|
22
|
+
.whenGiven('2026-01-01T00:00:00.000Z')
|
|
23
|
+
.thenReturn('hello world, it is 2026-01-01T00:00:00.000Z');
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Chain `thenYield` for each subsequent action, and finish with `thenReturn` or, for a void story, `thenComplete`. `whenGiven` also answers to `andReceive` and `withResponse` if one of those reads better at the call site.
|
|
27
|
+
|
|
28
|
+
This is the right tool when the order of actions is the thing you care about. When you only care about the outcome, `runStory` from `quidproquo-core` is simpler: it takes a map of mocks keyed by action type and hands you the return value.
|
|
29
|
+
|
|
30
|
+
## vitest matchers
|
|
31
|
+
|
|
32
|
+
The matchers register globally as a side effect, so they are not exported from the package root. Opt in explicitly:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import 'quidproquo-testing/vitest';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Status
|
|
39
|
+
|
|
40
|
+
Pre-1.0 and under active development. APIs change between releases.
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
[docs.quidproquojs.com](https://docs.quidproquojs.com)
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT. See [LICENSE](https://github.com/qpqjs/quidproquo/blob/main/LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-testing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"lib/**/*"
|
|
23
23
|
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
24
27
|
"scripts": {
|
|
25
28
|
"test": "vitest run",
|
|
26
29
|
"test:watch": "vitest",
|
|
@@ -35,17 +38,17 @@
|
|
|
35
38
|
},
|
|
36
39
|
"repository": {
|
|
37
40
|
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/
|
|
41
|
+
"url": "git+https://github.com/qpqjs/quidproquo.git"
|
|
39
42
|
},
|
|
40
43
|
"keywords": [],
|
|
41
44
|
"author": "",
|
|
42
45
|
"license": "MIT",
|
|
43
46
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/
|
|
47
|
+
"url": "https://github.com/qpqjs/quidproquo/issues"
|
|
45
48
|
},
|
|
46
|
-
"homepage": "https://github.com/
|
|
49
|
+
"homepage": "https://github.com/qpqjs/quidproquo#readme",
|
|
47
50
|
"devDependencies": {
|
|
48
|
-
"quidproquo-tsconfig": "0.1.
|
|
51
|
+
"quidproquo-tsconfig": "0.1.18",
|
|
49
52
|
"typescript": "^5.8.2",
|
|
50
53
|
"vitest": "^3.2.4"
|
|
51
54
|
},
|