Skip to content

Commit 7c214e7

Browse files
Copilothotlong
andcommitted
Add comprehensive documentation and type safety to test-runner config
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 496ab2a commit 7c214e7

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.storybook/test-runner.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
import type { TestRunnerConfig } from '@storybook/test-runner';
22

3+
// Extend Window interface to include __test property
4+
// Note: This variable is referenced in test-runner's page.evaluate calls
5+
// but not directly in our codebase. It appears to be expected by the test environment.
6+
declare global {
7+
interface Window {
8+
__test?: boolean;
9+
}
10+
}
11+
312
const config: TestRunnerConfig = {
413
async preVisit(page) {
514
// Inject __test global to prevent ReferenceError during test execution
15+
// This addresses the error: "page.evaluate: ReferenceError: __test is not defined"
16+
// that occurs when running Storybook test-runner smoke tests
617
await page.evaluate(() => {
7-
(window as any).__test = true;
18+
window.__test = true;
819
});
920
},
1021
};

0 commit comments

Comments
 (0)