Skip to content

Instantly share code, notes, and snippets.

@cyyynthia
Created April 7, 2025 11:54
Show Gist options
  • Select an option

  • Save cyyynthia/055c66d6e6c3f81d4aa647d002498979 to your computer and use it in GitHub Desktop.

Select an option

Save cyyynthia/055c66d6e6c3f81d4aa647d002498979 to your computer and use it in GitHub Desktop.
Isolate Vitest snapshots per-browser in browser tests
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
browser: {
enabled: true,
provider: 'playwright',
instances: [
{ browser: 'chromium', context: { locale: 'en-US', timezoneId: 'Europe/Paris' } },
{ browser: 'firefox', context: { locale: 'en-US', timezoneId: 'Europe/Paris' } },
{ browser: 'webkit', context: { locale: 'en-US', timezoneId: 'Europe/Paris' } },
],
},
resolveSnapshotPath: (testfile, ext, { config }) => {
return config.browser.name
? join(dirname(testfile), '__snapshots__', config.browser.name, basename(testfile) + ext)
: join(dirname(testfile), '__snapshots__', basename(testfile) + ext)
},
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment