Skip to content
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

[test] Update tests to pass react@next #26967

Merged
merged 4 commits into from
Jun 27, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,9 @@ describe('useAutocomplete', () => {
};

const devErrorMessages = [
!React.version.startsWith('18') &&
"Error: Uncaught [TypeError: Cannot read property 'removeAttribute' of null]",
Comment on lines -258 to -259
Copy link
Member Author

Choose a reason for hiding this comment

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

This was actually a bug reported in facebook/react#21712

"Error: Uncaught [TypeError: Cannot read property 'removeAttribute' of null]",
'Material-UI: Unable to find the input element.',
!React.version.startsWith('18') &&
"Error: Uncaught [TypeError: Cannot read property 'removeAttribute' of null]",
"Error: Uncaught [TypeError: Cannot read property 'removeAttribute' of null]",
'The above error occurred in the <ul> component',
// strict mode renders twice
React.version.startsWith('16') && 'The above error occurred in the <ul> component',
Expand Down
18 changes: 13 additions & 5 deletions test/utils/userEvent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { click, mouseDown, mouseUp } from './fireDiscreteEvent';
import { act, fireEvent } from './createClientRender';

Expand All @@ -7,9 +8,16 @@ export function touch(target: Element): void {
}

export function mousePress(target: Element): void {
mouseDown(target);
mouseUp(target);
click(target);
// Flush scheduled effects
act(() => {});
if (typeof (React as any).unstable_act === 'function') {
(React as any).unstable_act(() => {
mouseDown(target);
mouseUp(target);
click(target);
});
} else {
mouseDown(target);
mouseUp(target);
click(target);
act(() => {});
}
}