@solidrt/test 0.0.67 → 0.0.69
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/AGENTS.md +6 -2
- package/package.json +3 -3
- package/src/index.ts +20 -1
package/AGENTS.md
CHANGED
|
@@ -62,8 +62,12 @@ agents/testing.md.
|
|
|
62
62
|
(kind, label, text, box per line, no ids) to pin a layout or print it;
|
|
63
63
|
`locator.pixel(x, y)` is `[r, g, b, a]` at a point of the node and
|
|
64
64
|
`locator.pixels()` the whole image, drawn now with no time passing (the
|
|
65
|
-
last resort, for what only the picture shows); `
|
|
66
|
-
|
|
65
|
+
last resort, for what only the picture shows); `await
|
|
66
|
+
app.painted(locator)` runs one frame and returns what its paint drew of
|
|
67
|
+
the node, the capture riding the frame - the probe for a write made in
|
|
68
|
+
a frame being in that frame, where `pixels()` paints afresh after the
|
|
69
|
+
fact; `app.gpu({ label })` is the GPU inventory `/gpu` reports, where
|
|
70
|
+
"does it draw" is a count.
|
|
67
71
|
- The data folder and the fetch cache are empty at the start of every
|
|
68
72
|
test, and no gamepad is seated.
|
|
69
73
|
- A failure prints the app time and frame, what still demanded frames,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/test",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.69",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"funding": "https://github.com/sponsors/wellawaretech",
|
|
6
6
|
"author": "Antoine van Wel",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"AGENTS.md"
|
|
15
15
|
],
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@solidrt/flux-types": "0.0.
|
|
17
|
+
"@solidrt/flux-types": "0.0.69"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@solidrt/core": "0.0.
|
|
20
|
+
"@solidrt/core": "0.0.69"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { test as register, expect } from "flux:test"
|
|
18
18
|
import * as gui from "flux:test/gui"
|
|
19
|
-
import { capture, debug, frame as stepFrame, frameRate, inputPlan, inputStep, link, setFrameRate, settle, time, windowReady } from "sol:test"
|
|
19
|
+
import { capture, debug, frame as stepFrame, frameRate, inputPlan, inputStep, link, painted as paintFrame, setFrameRate, settle, time, windowReady } from "sol:test"
|
|
20
20
|
import { createElement, insert, render } from "@solidrt/core"
|
|
21
21
|
|
|
22
22
|
export { expect }
|
|
@@ -218,6 +218,19 @@ export interface TestApp {
|
|
|
218
218
|
* draws if anything demanded a draw.
|
|
219
219
|
*/
|
|
220
220
|
frame(count?: number): Promise<void>
|
|
221
|
+
/**
|
|
222
|
+
* Runs one frame and returns what its paint drew of the node: the
|
|
223
|
+
* capture is queued ahead of the frame, so the frame's own paint
|
|
224
|
+
* services it, and the image is that frame exactly as its callbacks,
|
|
225
|
+
* effects and the extensions' publishes drew it. The probe for "what a
|
|
226
|
+
* frame writes is in that frame", where `pixels()` paints the tree
|
|
227
|
+
* afresh after the fact. One frame of app time passes.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* let frame = await app.painted(leaf)
|
|
231
|
+
* expect(frame.data[0]).toBe(255)
|
|
232
|
+
*/
|
|
233
|
+
painted(target: Locator): Promise<Pixels>
|
|
221
234
|
/**
|
|
222
235
|
* Runs frames until `ms` of app time have passed: as many as it takes to
|
|
223
236
|
* cover it, so at 60 fps `advance(100)` is 6 frames. The frame is the
|
|
@@ -497,6 +510,12 @@ let app: TestApp = {
|
|
|
497
510
|
if (!Number.isInteger(count) || count < 0) throw new TypeError(`frame: the count must be a non-negative integer, got ${count}`)
|
|
498
511
|
for (let i = 0; i < count; i++) await stepFrame()
|
|
499
512
|
},
|
|
513
|
+
painted(target) {
|
|
514
|
+
// A locator is an object, a ref locator the ref function itself.
|
|
515
|
+
let locator = target !== null && (typeof target === "object" || typeof target === "function") && "record" in target
|
|
516
|
+
if (!locator) throw new TypeError("painted: give it a locator, the node whose paint to read")
|
|
517
|
+
return paintFrame(target.record.id)
|
|
518
|
+
},
|
|
500
519
|
advance(ms) {
|
|
501
520
|
if (typeof ms !== "number" || !(ms >= 0) || !Number.isFinite(ms)) throw new TypeError(`advance: the time must be a non-negative number of milliseconds, got ${ms}`)
|
|
502
521
|
return app.frame(framesFor(ms))
|