| 1 | import assert from "node:assert/strict"; |
| 2 | import test from "node:test"; |
| 3 | import { createTimings } from "./app-memory-timing.mjs"; |
| 4 | |
| 5 | test("timings count successful and failed waits without changing their results", async () => { |
| 6 | let clock = 0; |
| 7 | const timings = createTimings(() => clock); |
| 8 | assert.equal(await timings.measure("click", () => { clock += 3; return 42; }), 42); |
| 9 | const failure = new Error("navigation failed"); |
| 10 | await assert.rejects(timings.measure("click", () => { clock += 7; throw failure; }), error => error === failure); |
| 11 | assert.deepEqual(timings.snapshot(), { click: { count: 2, totalMs: 10, maxMs: 7 } }); |
| 12 | }); |
| 13 |