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
docs: waitForElementToBeRemoved
incorrect promise return type
#610
Labels
Comments
tjefferson08
added a commit
to tjefferson08/dom-testing-library
that referenced
this issue
Jun 13, 2020
There's a couple options here, as issue testing-library#610 enumerates nicely. 1) Resolve to the type param T Keeping references to removed elements is a probable source of bugs and confusing tests. A reference should be easy enough to obtain with other test utilities; I submit that there's no added value in providing it here. 2) Resolve to boolean (or literal `true`) Not a bad choice by any means, but not particularly meaningful (the fulfillment of the promise is signal enough IMO) 3) Resolve to something empty This is what I've gone with. We are _literally_ waiting for removal, after all :) Fixes testing-library#610
tjefferson08
added a commit
to tjefferson08/dom-testing-library
that referenced
this issue
Jun 13, 2020
There's a couple options here, as issue testing-library#610 enumerates nicely. 1) Resolve to the type param T Keeping references to removed elements is a probable source of bugs and confusing tests. A reference should be easy enough to obtain with other test utilities; I submit that there's no added value in providing it here. 2) Resolve to boolean (or literal `true`) Not a bad choice by any means, but not particularly meaningful (the fulfillment of the promise is signal enough IMO) 3) Resolve to something empty This is what I've gone with. We are _literally_ waiting for removal, after all :) Fixes testing-library#610
4 tasks
Hey @mdjastrzebski, I noticed this little hiccup as well! I jumped the gun and gave a PR a shot, maybe have a look if you're interested ❤️ |
@all-contributors please add @mdjastrzebski for bugs |
I've put up a pull request to add @mdjastrzebski! 🎉 |
🎉 This issue has been resolved in version 7.14.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@testing-library/dom
version: v7.10.1Relevant code or config:
N/A
What you did:
Read docs/types/code for
waitForElementToBeRemoved
.What happened:
Found discrepancy between declared return type for
waitForElementToBeRemoved
(docs & typescript types statePrimise<T>
) and actual implementation (Promise<true>
).Reproduction:
Compare docs or typescript types with
waitForElementToBeRemoved
implementation.Problem description:
Documentation, states the promise return type is
T
.With following declaration:
The same is declared in typescript types:
However
waitForElementToBeRemoved
implementation returns howevertrue
instead ofT
.Additionally, the same above docs later states that "Here is an example where the promise resolves with true because the element is removed:"
Suggested solution:
Make documentation and code agree with each other. For which I see 3 available options:
Promise<Boolean>
orPromise<true>
is used.true
, the code returns the initial value ofcallback
evaluation. This seems feasible, since in the implementation,callback
is immediately called in order to check that elements are initially present & and only then subsequently removed. We might capture that initial value, and return it to the caller. Hence resolving the promise withT
indeed.Promise<null>
. The advantage of this options is that it avoids usingBoolean
type where the return value is alwaystrue
hence does not add meaning.The text was updated successfully, but these errors were encountered: