-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I had some issues with React Testing Library for TS testing-library/react-testing-library#610
- Loading branch information
Showing
3 changed files
with
217 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { rest } from 'msw'; | ||
import { setupServer } from 'msw/node'; | ||
import { cleanup, render } from '@testing-library/react'; | ||
import { Calculator } from './calculator'; | ||
|
||
test('renders standard bonuses header', () => { | ||
const { getByText } = render(<Calculator />); | ||
const header = getByText(/standardowe bonusy/i); | ||
const server = setupServer( | ||
rest.get('/api/bonuses', (req, res, ctx) => { | ||
return res(ctx.json({ greeting: 'hello there' })); | ||
}) | ||
); | ||
|
||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
expect(header).toBeInTheDocument(); | ||
afterEach(cleanup); | ||
|
||
test('renders standard bonuses header', async () => { | ||
const { getByText } = render(<Calculator />); | ||
getByText(/standardowe bonusy/i); | ||
}); | ||
|
||
test('renders additional bonuses header', () => { | ||
const { getByText } = render(<Calculator />); | ||
const header = getByText(/dodatkowe bonusy/i); | ||
|
||
expect(header).toBeInTheDocument(); | ||
getByText(/dodatkowe bonusy/i); | ||
}); | ||
|
||
// test('renders target group', async () => { | ||
// const { getByText } = render(<Calculator />); | ||
// const nextButton = getByText(/dalej/i); | ||
|
||
// fireEvent.click(nextButton); | ||
// // https://github.com/testing-library/react-testing-library/issues/610 | ||
// await waitFor(() => getByText(/Target Group/i)); | ||
// }); |