Skip to content

Commit

Permalink
test: make react example more stable (#6324)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 12, 2024
1 parent 91dea8c commit 93abfa0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/react/test/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ test('Link changes the state when hovered', async () => {

await userEvent.hover(link)

expect(link).toHaveAccessibleName('Link is hovered')
await expect.poll(() => link).toHaveAccessibleName('Link is hovered')

await userEvent.unhover(link)

expect(link).toHaveAccessibleName('Link is normal')
await expect.poll(() => link).toHaveAccessibleName('Link is normal')
})
2 changes: 2 additions & 0 deletions test/browser/test/userEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const userEvent = _uE.setup()
describe('userEvent.click', () => {
test('correctly clicks a button', async () => {
const button = document.createElement('button')
button.style.height = '100px'
button.style.width = '200px'
button.textContent = 'Click me'
document.body.appendChild(button)
const onClick = vi.fn()
Expand Down
6 changes: 3 additions & 3 deletions test/ui/test/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test.describe('ui', () => {
// report
const sample = page.getByTestId('details-panel').getByLabel('sample.test.ts')
await sample.hover()
await sample.getByTestId('btn-open-details').click()
await sample.getByTestId('btn-open-details').click({ force: true })
await page.getByText('All tests passed in this file').click()

// graph tab
Expand All @@ -75,7 +75,7 @@ test.describe('ui', () => {
await page.goto(pageUrl)
const item = page.getByLabel('fixtures/console.test.ts')
await item.hover()
await item.getByTestId('btn-open-details').click()
await item.getByTestId('btn-open-details').click({ force: true })
await page.getByTestId('btn-console').click()
await page.getByText('/(?<char>\\w)/').click()

Expand All @@ -87,7 +87,7 @@ test.describe('ui', () => {
await page.goto(pageUrl)
const item = page.getByLabel('fixtures/error.test.ts')
await item.hover()
await item.getByTestId('btn-open-details').click()
await item.getByTestId('btn-open-details').click({ force: true })
await expect(page.getByTestId('diff')).toContainText('- Expected + Received + <style>* {border: 2px solid green};</style>')
})

Expand Down

0 comments on commit 93abfa0

Please sign in to comment.