Skip to content

chore: update react-native to 0.69.1 #1010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"flow-bin": "~0.170.0",
"flow-copy-source": "^2.0.9",
"jest": "^27.0.0",
"react": "^17.0.2",
"react-native": "~0.68.2",
"react-test-renderer": "^17.0.2",
"react": "^18.0.0",
"react-native": "~0.69.1",
"react-test-renderer": "^18.0.0",
"release-it": "^14.0.3",
"strip-ansi": "^6.0.0",
"typescript": "^4.0.2"
Expand Down
34 changes: 22 additions & 12 deletions src/__tests__/waitFor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,31 @@ test('waits for element with custom interval', async () => {
expect(mockFn).toHaveBeenCalledTimes(2);
});

test.each([TimerMode.Legacy, TimerMode.Modern])(
'waits for element until it stops throwing using %s fake timers',
async (fakeTimerType) => {
jest.useFakeTimers(fakeTimerType);
const { getByText, queryByText } = render(<BananaContainer />);
test('waits for element until it stops throwing using modern fake timers', async () => {
jest.useFakeTimers('modern');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could wait for Jest 28 PR to be merged first

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the test works, it just needs to be using two separate test entries instead of one test.each entries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing the test worked fine when each cause had only one of modern and legacy entries, but failed when there were both of them. I have a feeling that his is somehow connected to after test cleanup since splitting tests helped.

@thymikee maybe it make more sense to you as you know more about Jest internals.

const { getByText, queryByText } = render(<BananaContainer />);

fireEvent.press(getByText('Change freshness!'));
expect(queryByText('Fresh')).toBeNull();
fireEvent.press(getByText('Change freshness!'));
expect(queryByText('Fresh')).toBeNull();

jest.advanceTimersByTime(300);
const freshBananaText = await waitFor(() => getByText('Fresh'));
jest.advanceTimersByTime(300);
const freshBananaText = await waitFor(() => getByText('Fresh'));

expect(freshBananaText.props.children).toBe('Fresh');
}
);
expect(freshBananaText.props.children).toBe('Fresh');
});

test('waits for element until it stops throwing using legacy fake timers', async () => {
jest.useFakeTimers('legacy');
const { getByText, queryByText } = render(<BananaContainer />);

fireEvent.press(getByText('Change freshness!'));
expect(queryByText('Fresh')).toBeNull();

jest.advanceTimersByTime(300);
const freshBananaText = await waitFor(() => getByText('Fresh'));

expect(freshBananaText.props.children).toBe('Fresh');
});

test.each([TimerMode.Legacy, TimerMode.Modern])(
'waits for assertion until timeout is met with %s fake timers',
Expand Down
Loading