@shivaedev/test-story 0.10.0 → 0.11.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/CHANGELOG.md +6 -0
- package/README.md +24 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0 - 2026-10-18
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Pass a UTC `DateTime` to the existing `clock` option to pin a story or Effect fixture before its per-test setup runs. The exported `EffectClock` type now accepts `DateTime.Utc` alongside `"test"` and `"live"`. Hosts, workers and screens acquired with the story's Effect Context share native `Clock` / `TestClock`, including explicit `TestClock.adjust` advances; application code using `Clock` or `DateTime.now` needs no changes.
|
|
8
|
+
|
|
3
9
|
## 0.10.0 - 2026-10-18
|
|
4
10
|
|
|
5
11
|
### Added
|
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ This is the bakery kit this package tests itself with. `emptyBakery`, `stillWait
|
|
|
131
131
|
| `name` | What the engine is called in failures, "the bakery", and the kit's genre, "Bakery Story". |
|
|
132
132
|
| `outbound` | Optional. A map of exact hostnames to fake server origins for Node fetch and the DOM environment's document requests. |
|
|
133
133
|
| `around(effect)` | Optional. Wraps creation, staged seeding and the body; worker Layer acquisition remains outside it. It may require the worker services and per-test Scope. |
|
|
134
|
-
| `clock` | Optional. `"test"` by default,
|
|
134
|
+
| `clock` | Optional. `"test"` by default, `"live"` for real time, or a UTC `DateTime` to start TestClock at that instant. A story’s `options.clock` takes precedence. |
|
|
135
135
|
| `create()` | A fresh engine. Every story starts from a new one. |
|
|
136
136
|
| `layer` | Optional. The worker Effect layer that provides the services hooks, traits and test bodies use. Per-test Scope is already available to creation, staged and run hooks, traits and bodies. A hook that needs a service the layer does not provide does not compile, and neither does a test whose traits or body need one. |
|
|
137
137
|
| `stages` | The order traits are applied in. A trait names its stage, and one that names a stage the kit does not declare does not compile. |
|
|
@@ -379,6 +379,29 @@ bakery.it("tells each step into the story", [ovenIsLit()], function* ({ baker, o
|
|
|
379
379
|
|
|
380
380
|
A spec starts a story, acts through verbs and checks what a user would see. When it needs a setup or an action the kit lacks, add a trait or verb to the kit instead of building it in the spec.
|
|
381
381
|
|
|
382
|
+
### Pinning time
|
|
383
|
+
|
|
384
|
+
Pass a UTC `DateTime` as the story's `clock` option to pin time before its wrapper, creation, traits and hooks run. Code that uses `Clock` or `DateTime.now` reads that instant. Advance it explicitly with native `TestClock.adjust`:
|
|
385
|
+
|
|
386
|
+
```ts
|
|
387
|
+
import { DateTime } from "effect";
|
|
388
|
+
import * as TestClock from "effect/testing/TestClock";
|
|
389
|
+
|
|
390
|
+
app.it("shows the worker's date", [], function* ({ click, settle, text }) {
|
|
391
|
+
yield* click("button");
|
|
392
|
+
yield* settle();
|
|
393
|
+
expect(text("#worker")).toBe("Worker: since Oct 17");
|
|
394
|
+
yield* TestClock.adjust("1 day");
|
|
395
|
+
yield* click("button");
|
|
396
|
+
yield* settle();
|
|
397
|
+
expect(text("#worker")).toBe("Worker: since Oct 18");
|
|
398
|
+
}, { clock: DateTime.makeUnsafe("2026-10-17T12:34:56.000Z") });
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Acquire hosts, workers and screens in per-story Scope so they inherit the story's Clock. An independent runtime or native HTTP handler must capture the Effect Context at acquisition, as with `HttpEffect.toWebHandlerWith(context)` or `Effect.runPromiseWith(context)`. Worker-scoped kit `layer` acquisition stays outside the per-story clock; shared services acquired there do not acquire a new clock for each story. Direct JavaScript wall-time reads are not replaced. Formatting stays with the application, including its locale and time zone.
|
|
402
|
+
|
|
403
|
+
The [clock application stories](src/server/fixedClock.dom.spec.ts) run loopback HTTP, a queued worker that writes a timestamp to a file, and a DOM screen with its own Effect runner. They check exact timestamps and rendered dates, advancing time, and a live story without the option. A live-clock kit still runs on real time when a story omits the override.
|
|
404
|
+
|
|
382
405
|
### Running the engine
|
|
383
406
|
|
|
384
407
|
Hooks and steps that wait for real workers can use `withLive(Effect.sleep(...))` or `withLive(eventually(...))` from `@shivaedev/effect-test/withLive.ts` and `@shivaedev/effect-test/eventually.ts`. Both work under the kit's live clock and a story's TestClock override. The wrapped work uses live time without advancing the story's virtual time; outside it, the selected clock still applies. Unwrapped `eventually` uses the active clock and advances TestClock between attempts.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/test-story",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Tests that read like stories over the real engine: a story kit per engine with its own it, traits per feature, and a failure that prints the story, where it stopped and the engine's state",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/test-story#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"README.md"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@shivaedev/effect-test": "0.
|
|
44
|
+
"@shivaedev/effect-test": "0.7.0",
|
|
45
45
|
"dom-accessibility-api": "0.7.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|