Skip to content

Commit

Permalink
Fix "Warning: It looks like you're using the wrong act() around your …
Browse files Browse the repository at this point in the history
…test interactions."

See facebook/react#14769 (comment)
  • Loading branch information
tkrotoff committed Sep 21, 2019
1 parent 42b2c8b commit 8334da0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Router.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import TestRenderer from 'react-test-renderer';
import { create, act } from 'react-test-renderer';
import { wait } from '@testing-library/react';
import { MemoryRouter } from 'react-router';

Expand All @@ -11,7 +11,7 @@ import { Router } from './Router';
jest.mock('./api/Marvel');

function renderRoute(path: string) {
return TestRenderer.create(
return create(
<MemoryRouter initialEntries={[path]}>
<Router />
</MemoryRouter>
Expand All @@ -20,7 +20,7 @@ function renderRoute(path: string) {

test('HeroesPagination route', async () => {
const wrapper = renderRoute('/');
await wait();
await act(() => wait());
expect(wrapper.root.findAllByType(HeroesPagination)).toHaveLength(1);
expect(wrapper.root.findAllByType(Hero)).toHaveLength(0);
expect(wrapper.root.findAllByType(PageNotFound)).toHaveLength(0);
Expand All @@ -29,7 +29,7 @@ test('HeroesPagination route', async () => {

test('Hero route', async () => {
const wrapper = renderRoute('/heroes/1011334');
await wait();
await act(() => wait());
expect(wrapper.root.findAllByType(HeroesPagination)).toHaveLength(0);
expect(wrapper.root.findAllByType(Hero)).toHaveLength(1);
expect(wrapper.root.findAllByType(PageNotFound)).toHaveLength(0);
Expand Down

0 comments on commit 8334da0

Please sign in to comment.