webdriverio/e2e/browser-runner/pr-eact.test.tsx
Christian Bromann 4afd9f2d20
[💡 Feature]: Replace shadowFnFactory with WebDriver shadow command (#9911)
* Replace shadow commands with WebDriver implementation

* move component testing examples into e2e test

* adjust component testing example

* push missing env file

* fall back to old behavior for Firefox
2023-03-08 09:53:12 +01:00

23 lines
871 B
TypeScript

import { expect } from 'expect'
import { render, fireEvent, screen, waitFor } from '@testing-library/preact'
import '@testing-library/jest-dom'
import { Counter } from './components/PreactComponent.jsx'
describe('Preact Component Testing', () => {
it('should display initial count', () => {
const { container } = render(<Counter initialCount={5} />)
expect(container.textContent).toMatch('Current value: 5')
})
it('should increment after "Increment" button is clicked', async () => {
render(<Counter initialCount={5} />)
fireEvent.click(screen.getByText('Increment'))
await waitFor(() => {
// .toBeInTheDocument() is an assertion that comes from jest-dom.
// Otherwise you could use .toBeDefined().
expect(screen.getByText('Current value: 6')).toBeDefined()
})
})
})