Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

browser-test.ts

30 lines1012 Bytes

1import { mkdtemp, rm } from 'node:fs/promises'
2import { tmpdir } from 'node:os'
3import { join } from 'node:path'
4import { test as base, webkit } from '@playwright/test'
5​
6// WebKit's ephemeral profile may reject native Blob preparation. Run the SAME
7// value histories in a disposable persistent profile as a positive receiving
8// witness, while retaining the ordinary profile's truthful-rejection coverage.
9export const test = base.extend({
10 context: async ({ context }, use, info) => {
11 if (info.project.name !== 'webkit-persistent') {
12 await use(context)
13 return
14 }
15 const profile = await mkdtemp(join(tmpdir(), 'indexeddb-webkit-'))
16 try {
17 const persistent = await webkit.launchPersistentContext(profile, {
18 headless: true,
19 baseURL: String(info.project.use.baseURL),
20 })
21 try {
22 await use(persistent)
23 } finally {
24 await persistent.close()
25 }
26 } finally {
27 await rm(profile, { recursive: true, force: true })
28 }
29 },
30})