@lewiswright/vitest-plugin-vis
Version:
Vitest visual testing plugin
17 lines (15 loc) • 507 B
text/typescript
import type { BrowserCommandContext } from 'vitest/node'
import type { BrowserApi } from './types.ts'
export function playwright(context: BrowserCommandContext): BrowserApi {
return {
async takeScreenshot(filePath, selector, options) {
// The `Locator` type from `vitest` has less props than the `Locator` in `playwright`
const subject = context.iframe.locator(selector)
return subject.screenshot({
timeout: options?.timeout,
animations: 'disabled',
path: filePath,
})
},
}
}