You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by douglasjunior October 28, 2022
In one test case we called a function within ACT that ESLint indicates is a testing-library function, but is not.
And dismissCallback need to be wrapped with act because it dispatches a state update to close the AlertModal.
it('should not auto close modal with autoDismiss=false',async()=>{constmockOnDismiss=jest.fn();letdismissCallback: undefined|(()=>void);consttree=render(<AlertModalvisibletitle="Title"description="Lorem ipsum is placeholder text commonly used in the graphic"primaryButtonName="Primary Action"secondaryButtonName="Secondary Action"autoDismiss={false}onPressSecondary={event=>{dismissCallback=event.dismiss;}}onDismiss={mockOnDismiss}/>,);constbuttonInstance=tree.getByTestId('alert-modal-secondary-button');fireEvent.press(buttonInstance);expect(dismissCallback).toBeDefined();expect(mockOnDismiss).not.toBeCalled();act(()=>{dismissCallback?.();});expect(mockOnDismiss).toHaveBeenCalled();
This has been confirmed as a false positive. Removing the optional chaining from dismissCallback call fixes the issue:
But wrapping it in an if statement gets the problem back:
This seems related to the fact that CallExpression is not a direct child of the function body, so we are not detecting this correctly.
The text was updated successfully, but these errors were encountered:
Discussed in #685
Originally posted by douglasjunior October 28, 2022
In one test case we called a function within ACT that ESLint indicates is a testing-library function, but is not.
And
dismissCallback
need to be wrapped withact
because it dispatches a state update to close the AlertModal.This has been confirmed as a false positive. Removing the optional chaining from
dismissCallback
call fixes the issue:But wrapping it in an if statement gets the problem back:
This seems related to the fact that
CallExpression
is not a direct child of the function body, so we are not detecting this correctly.The text was updated successfully, but these errors were encountered: