-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Suggestion: Export withPromise for easier typing in typescript tests #3133
Comments
Personally, I'm a little torn on this. Of course, turning a
Rather, it can actually, I believe, lead to uncaught bugs in tests. The reason being that it encourages testing a single case one by one. So, I think However, this kind of mocking isn't perfect and doesn't handle:
In short, I'd much rather bite the bullet and think about mocking utilities that emulate the full So, instead, I think it's time to maybe think about
How does that sound? |
I spoke too soon, I'm in the midst of upgrading and withPromise definitely doesn't work with subscriptions (as you implied). +additional side note, using I agree with the testing library. Having used Urql since 1.x I have bits and pieces of test utilities all over the place in different projects and having a more first-class library would be a great addition. I like the idea of doing it via an exchange, we do something similar to test relay pagination. Happy to take a stab at making an initial PR for that. |
https://github.com/urql-graphql/urql/blob/9cdb74b03e07d46e056ef023d1543f24a823ec55/packages/core/src/utils/streamUtils.ts
If you're coming from v3 -> v4 in typescript the following results in a type error because this is a
Source<OperationResult>
instead ofOperationResultSource<OperationResult>
:It's a small thing but I think it is better to have access to the util than use
as OperationResultSource<OperationResult>
for anyone consuming the library.The text was updated successfully, but these errors were encountered: