@fairfox/polly 0.86.0 → 0.88.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.
@@ -11,7 +11,71 @@ export interface FileTally {
11
11
  passed: number;
12
12
  failed: number;
13
13
  }
14
+ /** One test's outcome, as the in-page harness reports it. */
15
+ export interface TestResult {
16
+ name: string;
17
+ passed: boolean;
18
+ error?: string;
19
+ }
20
+ /**
21
+ * What the page pushes to the runner as it works through a file.
22
+ *
23
+ * The final `__pollyReport` call carries the whole tally, but it never
24
+ * arrives when the page stops running. These events arrive as the suite
25
+ * goes, so a timed-out file can still say how far it got (polly#177).
26
+ */
27
+ export type ProgressEvent = {
28
+ kind: "plan";
29
+ total: number;
30
+ } | {
31
+ kind: "start";
32
+ name: string;
33
+ } | {
34
+ kind: "result";
35
+ name: string;
36
+ passed: boolean;
37
+ error?: string;
38
+ };
39
+ /** Everything the page managed to say before it went quiet. */
40
+ export interface SuiteProgress {
41
+ /** Test count the page announced up front; absent if it never got that far. */
42
+ planned?: number;
43
+ /** Names of tests that began, in order. */
44
+ started: string[];
45
+ /** Outcomes of tests that finished. */
46
+ completed: TestResult[];
47
+ }
48
+ /**
49
+ * What the renderer was doing when the file timed out.
50
+ *
51
+ * - `looping` — the main thread never yielded, so JavaScript is still
52
+ * running: a runaway loop in the code under test.
53
+ * - `idle` — the page answers, so the thread is free; an awaited
54
+ * promise never settled, or `done()` was never called.
55
+ * - `unknown` — the state could not be probed (the page or the browser
56
+ * had already gone).
57
+ */
58
+ export type StallState = "looping" | "idle" | "unknown";
14
59
  export declare function errMessage(err: unknown): string;
60
+ /** Empty progress, for a file whose page said nothing at all. */
61
+ export declare function emptyProgress(): SuiteProgress;
62
+ /** Fold one page-pushed event into the accumulated progress. */
63
+ export declare function applyProgress(progress: SuiteProgress, event: ProgressEvent): void;
64
+ /**
65
+ * Turn a timed-out file into a tally and the lines to print for it.
66
+ *
67
+ * A timed-out file used to count as a single failure, so the tests it held
68
+ * vanished from the run's totals with no indication — a 9-test file that
69
+ * stalled on its 4th test reported `1 failed` and the tier's count silently
70
+ * lost 9 tests (polly#177). Every test the page announced is now accounted
71
+ * for: the ones that finished keep their real outcome, and the ones that
72
+ * never ran are counted as failures so the tier's total still matches the
73
+ * number of tests in the files.
74
+ */
75
+ export declare function summariseTimeout(progress: SuiteProgress, timeoutMs: number, state: StallState): {
76
+ tally: FileTally;
77
+ lines: string[];
78
+ };
15
79
  /**
16
80
  * Run every test file, isolating each file's failure.
17
81
  *
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Minimal source-map lookup for the browser runner's stack reports.
3
+ *
4
+ * When a page wedges, the runner pauses it and prints the frames it was
5
+ * executing. Those positions are in the served bundle, which is one long
6
+ * generated file — "(inline):199:4" names the right line of the wrong file.
7
+ * Resolving them through the bundle's own inline source map turns the report
8
+ * into the position in the test or component the author wrote (polly#177).
9
+ *
10
+ * Only what that needs is implemented: decode `mappings`, and answer
11
+ * "which original position covers this generated one". No names, no
12
+ * `sourcesContent`, no index maps — Bun.build does not emit those here.
13
+ */
14
+ interface SourceMap {
15
+ sources: string[];
16
+ mappings: string;
17
+ }
18
+ /** Resolves a generated position to `source:line:column`, or undefined. */
19
+ export type SourceMapLookup = (line: number, column: number) => string | undefined;
20
+ /** Pull the inline source map out of a bundle, if it carries one. */
21
+ export declare function parseInlineSourceMap(bundle: string): SourceMap | undefined;
22
+ /**
23
+ * Build a lookup over a bundle's inline source map.
24
+ *
25
+ * `lineOffset` is how many lines of wrapper HTML sit above the bundle in the
26
+ * served document, since the debugger reports positions in the document, not
27
+ * in the script. Returns undefined when the bundle carries no usable map, so
28
+ * callers can fall back to the raw generated position.
29
+ */
30
+ export declare function createSourceMapLookup(bundle: string, lineOffset?: number): SourceMapLookup | undefined;
31
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairfox/polly",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Multi-execution-context framework with reactive state and cross-context messaging for Chrome extensions, PWAs, and worker-based applications",