Skip to content

Commit

Permalink
[test] Update tests to pass react@next (#26967)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jun 27, 2021
1 parent 744d215 commit 17168d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
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]",
"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(() => {});
}
}

0 comments on commit 17168d2

Please sign in to comment.