Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132import { expect, test } from 'vitest'import { instances, runBrowserTests } from './utils'
test('locator error format aria', async () => { const result = await runBrowserTests({ root: './fixtures/locator-error-format', browser: { locators: { errorFormat: 'aria', }, }, })
const trees = result.errorTree({ project: true }) for (const { browser } of instances) { const tree = trees[browser] expect.soft(tree, browser).toMatchInlineSnapshot(` { "basic.test.ts": { "not found": [ "Cannot find element with locator: getByRole('button', { name: 'Save' })
ARIA tree: - main: - heading "Settings" [level=1] - button "Cancel"", ], }, } `) }})
test('locator error format html', async () => { const result = await runBrowserTests({ root: './fixtures/locator-error-format', browser: { locators: { errorFormat: 'html', }, }, })
const trees = result.errorTree({ project: true }) for (const { browser } of instances) { const tree = trees[browser] expect.soft(tree, browser).toMatchInlineSnapshot(` { "basic.test.ts": { "not found": [ "Cannot find element with locator: getByRole('button', { name: 'Save' })
<body> <main> <h1> Settings </h1> <button> Cancel </button> </main> </body>", ], }, } `) }})
test('locator error format all', async () => { const result = await runBrowserTests({ root: './fixtures/locator-error-format', browser: { locators: { // default // errorFormat: 'all', }, }, })
const trees = result.errorTree({ project: true }) for (const { browser } of instances) { const tree = trees[browser] expect.soft(tree, browser).toMatchInlineSnapshot(` { "basic.test.ts": { "not found": [ "Cannot find element with locator: getByRole('button', { name: 'Save' })
ARIA tree: - main: - heading "Settings" [level=1] - button "Cancel"
HTML: <body> <main> <h1> Settings </h1> <button> Cancel </button> </main> </body>", ], }, } `) }})