@triggery/testing 0.1.0 → 0.1.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/CHANGELOG.md +16 -0
- package/README.md +49 -8
- package/package.json +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @triggery/testing
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 35936d1: Polished package metadata for framework-agnostic positioning.
|
|
8
|
+
|
|
9
|
+
- `@triggery/core` description corrected: it is **framework-agnostic** (React, Solid, Vue, or any binding you write), not React-only. Keywords now include `solid`, `vue`, `framework-agnostic`, `zero-dependencies`. README expanded to spell out what runs where.
|
|
10
|
+
- `@triggery/testing` README + description now mention **zero runtime dependencies** and that the kit works under Vitest, Jest, and `node:test` alike (no `vi.useFakeTimers` coupling).
|
|
11
|
+
- `@triggery/devtools-bridge`, `@triggery/devtools-redux`, `@triggery/vite` descriptions clarified as framework-agnostic / runtime-pure.
|
|
12
|
+
- `@triggery/react / solid / vue` descriptions now explicitly say **zero runtime dependencies** — the binding is a thin lifecycle adapter, nothing else.
|
|
13
|
+
|
|
14
|
+
No API or behaviour changes.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [35936d1]
|
|
17
|
+
- @triggery/core@0.1.1
|
|
18
|
+
|
|
3
19
|
## 0.1.0
|
|
4
20
|
|
|
5
21
|
First public preview release.
|
package/README.md
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
# @triggery/testing
|
|
2
2
|
|
|
3
|
-
Testing utilities for [Triggery](https://github.com/triggeryjs/triggery).
|
|
4
|
-
|
|
5
|
-
Provides:
|
|
6
|
-
|
|
7
|
-
- `createTestRuntime({ triggers })` — isolated runtime for tests.
|
|
8
|
-
- `mockCondition(name, value)` / `mockAction(name, fn)` — replace ports without rendering React.
|
|
9
|
-
- `fakeScheduler` — control time (advance, flush).
|
|
10
|
-
- Vitest and Jest adapters.
|
|
3
|
+
Testing utilities for [Triggery](https://github.com/triggeryjs/triggery). **Zero runtime dependencies. Framework-agnostic** — works the same in React, Solid, Vue tests, Node, or a worker; works with Vitest, Jest, and `node:test`.
|
|
11
4
|
|
|
12
5
|
## Install
|
|
13
6
|
|
|
@@ -15,6 +8,54 @@ Provides:
|
|
|
15
8
|
pnpm add -D @triggery/testing
|
|
16
9
|
```
|
|
17
10
|
|
|
11
|
+
## What's in the box
|
|
12
|
+
|
|
13
|
+
- `createTestRuntime({ triggers? })` — isolated runtime per test (no global state pollution).
|
|
14
|
+
- `mockCondition(trigger, name, value | getter)` — supply a condition without rendering a component.
|
|
15
|
+
- `mockAction(trigger, name, fn)` — register an action handler (typically `vi.fn()` / `jest.fn()` / a closure).
|
|
16
|
+
- `flushMicrotasks()` — drain the default microtask scheduler before asserting.
|
|
17
|
+
- `createFakeScheduler()` — controllable virtual clock for `actions.debounce / throttle / defer`:
|
|
18
|
+
- `install()` / `uninstall()` swap `globalThis.setTimeout` / `clearTimeout` for a controlled implementation.
|
|
19
|
+
- `advance(ms)` runs every timer due within the window and drains microtasks.
|
|
20
|
+
- `flushAll()` runs every pending timer regardless of scheduled time.
|
|
21
|
+
- Test-runner agnostic — no dependency on `vi.useFakeTimers()`.
|
|
22
|
+
|
|
23
|
+
## Example
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createTrigger } from '@triggery/core';
|
|
27
|
+
import { createTestRuntime } from '@triggery/testing';
|
|
28
|
+
import { expect, test, vi } from 'vitest';
|
|
29
|
+
|
|
30
|
+
test('mod with sound shows toast and plays sound', async () => {
|
|
31
|
+
const rt = createTestRuntime();
|
|
32
|
+
const t = createTrigger<{
|
|
33
|
+
events: { 'new-message': string };
|
|
34
|
+
conditions: { user: { isMod: boolean } };
|
|
35
|
+
actions: { showToast: string; playSound: 'beep' | 'mod-alert' };
|
|
36
|
+
}>(
|
|
37
|
+
{
|
|
38
|
+
id: 'msg',
|
|
39
|
+
events: ['new-message'],
|
|
40
|
+
required: ['user'],
|
|
41
|
+
handler: ({ event, conditions, actions, check }) => {
|
|
42
|
+
if (!check.is('user', (u) => u.isMod)) return;
|
|
43
|
+
actions.showToast?.(event.payload);
|
|
44
|
+
actions.playSound?.('mod-alert');
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
rt,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
rt.mockCondition(t, 'user', { isMod: true });
|
|
51
|
+
const showToast = vi.fn();
|
|
52
|
+
rt.mockAction(t, 'showToast', showToast);
|
|
53
|
+
|
|
54
|
+
rt.fireSync('new-message', 'hi');
|
|
55
|
+
expect(showToast).toHaveBeenCalledWith('hi');
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
18
59
|
## License
|
|
19
60
|
|
|
20
61
|
MIT © Aleksey Skhomenko
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triggery/testing",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Testing utilities for Triggery — isolated runtime, mock conditions/actions,
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Testing utilities for Triggery — isolated runtime, fake scheduler, mock conditions/actions. Zero runtime dependencies, works with Vitest / Jest / node:test.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aleksey Skhomenko",
|
|
7
7
|
"homepage": "https://triggeryjs.github.io/triggery",
|
|
@@ -26,7 +26,11 @@
|
|
|
26
26
|
"testing",
|
|
27
27
|
"vitest",
|
|
28
28
|
"jest",
|
|
29
|
-
"
|
|
29
|
+
"node-test",
|
|
30
|
+
"mocking",
|
|
31
|
+
"fake-timers",
|
|
32
|
+
"zero-dependencies",
|
|
33
|
+
"framework-agnostic"
|
|
30
34
|
],
|
|
31
35
|
"type": "module",
|
|
32
36
|
"main": "./dist/index.js",
|
|
@@ -49,16 +53,17 @@
|
|
|
49
53
|
],
|
|
50
54
|
"sideEffects": false,
|
|
51
55
|
"publishConfig": {
|
|
52
|
-
"access": "public"
|
|
56
|
+
"access": "public",
|
|
57
|
+
"provenance": true
|
|
53
58
|
},
|
|
54
59
|
"peerDependencies": {
|
|
55
|
-
"@triggery/core": "0.1.
|
|
60
|
+
"@triggery/core": "0.1.1"
|
|
56
61
|
},
|
|
57
62
|
"devDependencies": {
|
|
58
63
|
"tsup": "^8.5.1",
|
|
59
64
|
"typescript": "^6.0.3",
|
|
60
65
|
"vitest": "^4.1.6",
|
|
61
|
-
"@triggery/core": "0.1.
|
|
66
|
+
"@triggery/core": "0.1.1"
|
|
62
67
|
},
|
|
63
68
|
"scripts": {
|
|
64
69
|
"build": "tsup",
|