@alexgorbatchev/storybook-test-runner-bun 1.0.4 → 1.0.5
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/README.md +1 -1
- package/package.json +1 -1
- package/src/runStories.ts +23 -20
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ Existing stories and browser-side `storybook/test` imports stay as they are. Cha
|
|
|
118
118
|
|
|
119
119
|
# Browser Coverage
|
|
120
120
|
|
|
121
|
-
The runner starts Playwright's native JavaScript coverage before navigating to the Storybook preview. Chromium tracks execution without instrumenting your application. Relative source-map filenames resolve against their served module, preserving directories in Vite development coverage. With a coverage filter, unrelated scripts and inline source maps are discarded after each
|
|
121
|
+
The runner starts Playwright's native JavaScript coverage before navigating to the Storybook preview. Chromium tracks execution without instrumenting your application. Relative source-map filenames resolve against their served module, preserving directories in Vite development coverage. With a coverage filter, unrelated scripts and inline source maps are discarded after each page lifecycle to avoid retaining repeated dependency sources. Coverage stays active across stories sharing a page, retaining execution of previously loaded functions. External maps are resolved by Monocart. Monocart merges the results, maps bundled code back to original sources, and generates reports. Enable source maps in your Storybook build (for Bun builds, use `sourcemap: "inline"`) and make external source maps accessible to the runner if used.
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
124
|
const results = await runStories({
|
package/package.json
CHANGED
package/src/runStories.ts
CHANGED
|
@@ -70,7 +70,7 @@ export async function runStories(options: RunnerOptions): Promise<StoryResult[]>
|
|
|
70
70
|
removeErrorListener = () => {
|
|
71
71
|
page.off("pageerror", onError);
|
|
72
72
|
};
|
|
73
|
-
if (options.coverageDirectory) await page.coverage.startJSCoverage();
|
|
73
|
+
if (options.coverageDirectory && !existing) await page.coverage.startJSCoverage();
|
|
74
74
|
if (!existing && options.prepare)
|
|
75
75
|
await runHook(
|
|
76
76
|
() =>
|
|
@@ -106,28 +106,31 @@ export async function runStories(options: RunnerOptions): Promise<StoryResult[]>
|
|
|
106
106
|
};
|
|
107
107
|
} finally {
|
|
108
108
|
removeErrorListener?.();
|
|
109
|
-
try {
|
|
110
|
-
if (options.coverageDirectory) {
|
|
111
|
-
const page = context.pages()[0];
|
|
112
|
-
if (page) {
|
|
113
|
-
const entries = await page.coverage.stopJSCoverage();
|
|
114
|
-
hasCoverageEntries ||= entries.length > 0;
|
|
115
|
-
coverage.push(
|
|
116
|
-
...(coverageGlob
|
|
117
|
-
? entries.filter((entry) => coverageEntryMatches(entry, coverageGlob))
|
|
118
|
-
: entries),
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} catch (error) {
|
|
123
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
124
|
-
const result = results[index];
|
|
125
|
-
if (result) result.error = [result.error, message].filter(Boolean).join("\n");
|
|
126
|
-
}
|
|
127
109
|
}
|
|
128
110
|
}
|
|
129
111
|
} finally {
|
|
130
|
-
|
|
112
|
+
try {
|
|
113
|
+
if (options.coverageDirectory) {
|
|
114
|
+
const page = context.pages()[0];
|
|
115
|
+
if (page) {
|
|
116
|
+
const entries = await page.coverage.stopJSCoverage();
|
|
117
|
+
hasCoverageEntries ||= entries.length > 0;
|
|
118
|
+
coverage.push(
|
|
119
|
+
...(coverageGlob
|
|
120
|
+
? entries.filter((entry) => coverageEntryMatches(entry, coverageGlob))
|
|
121
|
+
: entries),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} catch (error) {
|
|
126
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
+
for (const { index } of suite) {
|
|
128
|
+
const result = results[index];
|
|
129
|
+
if (result) result.error = [result.error, message].filter(Boolean).join("\n");
|
|
130
|
+
}
|
|
131
|
+
} finally {
|
|
132
|
+
await context.close();
|
|
133
|
+
}
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
}),
|