-
Notifications
You must be signed in to change notification settings - Fork 275
feature: wait for element to be removed #376
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
Conversation
src/waitForElementToBeRemoved.js
Outdated
export default async function waitForElementToBeRemoved<T>( | ||
expectation: () => T, | ||
options?: WaitForOptions | ||
): Promise<null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if null
is a proper type here. But we do not have anything meaningful to return.
RTL declares its version in TS as Promise<T>
but uses return true
in their impl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO I would keep the Promise<T>
return type and return the initial result of expectation
call. Since in code we require that initially expectation
is successful (returns something) and only then starts throwing/returning nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, let's do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also logged issue in Dom TL that they have similar discrepancy.
e2fb263
to
1143370
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed is that using useFakeTimers('modern')
doesn't work with neither of waitFor
helpers. We need to figure this as well before it ships as default in Jest 27. But for now, this LGTM 👍
:::info | ||
In order to properly use `waitFor` you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.60 (which comes with React >=16.9.0). | ||
::: | ||
|
||
If you're using Jest's [Timer Mocks](https://jestjs.io/docs/en/timer-mocks#docsNav), remember not to use `async/await` syntax as it will stall your tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for later: we need to figure out why this happens.
Summary
waitForElementToBeRemoved
implementation with tests & typescript types.Resolves #375
Test plan
Added tests based on
waitFor
& veryfinggetBy
,getAllBy
,queryBy
&queryAllBy
queries.