@triggery/testing 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +55 -8
  3. package/package.json +11 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @triggery/testing
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f23e155: Filled out the quick-start sections in the npm package READMEs that adopters land on first.
8
+
9
+ - `@triggery/core` README now contains a three-tab quick-start (React / Solid / Vue) with concrete `pnpm add` commands and runnable code, plus pointers to the per-binding README for the full walkthrough.
10
+ - `@triggery/react` README — was a stub. Now has the full four-file scenario (trigger + provider + Chat + Toast) ready to copy-paste, exactly mirroring the Solid and Vue examples.
11
+
12
+ Linked-bundle bump so the binding READMEs stay aligned with the core release; no code or API changes.
13
+
14
+ - 3385f5b: Every package README now ends with a tailored **Related packages** section and a consistent `## License` footer.
15
+
16
+ - Adapter packages (`zustand`, `redux`, `jotai`, `mobx`, `reatom`, `signals`, `query`) link to `core` + `react` (required peers) plus 2-3 alternative adapters so adopters can swap them out without re-reading the whole repo.
17
+ - Event-source packages (`dom`, `socket`) cross-link.
18
+ - DevTools packages (`devtools-redux`, `devtools-panel`, `devtools-bridge`) cross-link.
19
+ - Tooling packages (`eslint-plugin`, `codemod`, `cli`) cross-link.
20
+ - Bindings (`react`, `solid`, `vue`) link to each other so users mid-migration know there's a sibling with the same hook API.
21
+ - `@triggery/core/src/index.ts` JSDoc header had stale wording ("orchestration runtime for React business logic") — replaced with framework-agnostic phrasing matching the README.
22
+
23
+ No code or API changes. Drop-in patch.
24
+
25
+ - Updated dependencies [f23e155]
26
+ - Updated dependencies [3385f5b]
27
+ - @triggery/core@0.1.2
28
+
29
+ ## 0.1.1
30
+
31
+ ### Patch Changes
32
+
33
+ - 35936d1: Polished package metadata for framework-agnostic positioning.
34
+
35
+ - `@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.
36
+ - `@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).
37
+ - `@triggery/devtools-bridge`, `@triggery/devtools-redux`, `@triggery/vite` descriptions clarified as framework-agnostic / runtime-pure.
38
+ - `@triggery/react / solid / vue` descriptions now explicitly say **zero runtime dependencies** — the binding is a thin lifecycle adapter, nothing else.
39
+
40
+ No API or behaviour changes.
41
+
42
+ - Updated dependencies [35936d1]
43
+ - @triggery/core@0.1.1
44
+
3
45
  ## 0.1.0
4
46
 
5
47
  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,60 @@ 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
+
59
+ ## Related packages
60
+
61
+ - [`@triggery/core`](https://www.npmjs.com/package/@triggery/core) — Required peer — `createTestRuntime` wraps `createRuntime`.
62
+
63
+ See the [full package list](https://github.com/triggeryjs/triggery#packages) in the repo README.
64
+
18
65
  ## License
19
66
 
20
67
  MIT &copy; Aleksey Skhomenko
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@triggery/testing",
3
- "version": "0.1.0",
4
- "description": "Testing utilities for Triggery — isolated runtime, mock conditions/actions, fake scheduler",
3
+ "version": "0.1.2",
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
- "mocking"
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.0"
60
+ "@triggery/core": "0.1.2"
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.0"
66
+ "@triggery/core": "0.1.2"
62
67
  },
63
68
  "scripts": {
64
69
  "build": "tsup",