Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion e2e/test-helpers/storybook.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import fs from 'node:fs'
import path from 'node:path'
import {parseSync, traverse, types as t} from '@babel/core'
import type {Page} from '@playwright/test'
import {kebabCase} from 'change-case'
import {waitForImages} from './waitForImages'

const AVATAR_IMAGE_PATH = path.join(__dirname, '../../packages/react/static/mock-avatar.png')

type Value =
| string
| boolean
Expand Down Expand Up @@ -61,7 +64,7 @@ async function visit(page: Page, options: Options) {

/** Mock live avatar urls to make them stable for visual diffing (vrt) */
await page.route('https://github.com/*.png', async route => {
await route.continue({url: 'https://github.com/primer.png'})
await route.fulfill({path: AVATAR_IMAGE_PATH})
})
Comment on lines 65 to 68
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route mock only matches https://github.com/*.png, but several VRT-covered stories still request avatars from https://avatars.githubusercontent.com/... (e.g. packages/react/src/Avatar/Avatar.stories.tsx). Those requests will still hit the network and can still flake, which undermines the goal of making VRT independent of external avatar fetches. Consider adding an additional page.route for https://avatars.githubusercontent.com/** (and any other avatar hosts you use) to fulfill with the same local image, or broadening the existing matcher accordingly.

Copilot uses AI. Check for mistakes.

await page.goto(url.toString())
Expand Down
2 changes: 2 additions & 0 deletions packages/react/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const config: StorybookConfig = {
: // Don't include dev stories in production
['../src/**/*.mdx', '../src/**/!(*.dev).stories.@(js|jsx|ts|tsx)'],

staticDirs: ['../static'],

addons: [
getAbsolutePath('@storybook/addon-a11y'),
getAbsolutePath('@storybook/addon-links'),
Expand Down
Binary file added packages/react/static/mock-avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading