-
Notifications
You must be signed in to change notification settings - Fork 971
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]: Outdated / incomplete doc regarding async directive testing #10812
Comments
Hi @Firokat and thanks for using directives and tests — and reporting this. I’ll have to go back as see why we had the specific async mock and when it was removed. Your approach to resolve or reject seems sensible and depending on what I find that might be the docs update we need. Very helpful to have the reproduction here. Thanks! |
FYI some history is here #5822 So your method of testing is correct — I’ll make a docs change to clarify how to test async directives properly. Thanks! |
Hi, thanks for looking into this as quickly as you did ! |
…ains how to test async directives (#10827) Fixes #10812 This PR removes `mockAsyncRedwoodDirective` from documentation and properly show how to test async directives using `resolves` and `rejects`. History: mockAsyncRedwoodDirective was an early implementation but after PR review it was determined that a separate functions wasn't needed, but the resolves/rejects could be uses by making mockRedwoodDirective handle promises better. However, the documentation retained the older reference. --------- Co-authored-by: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com>
…ains how to test async directives (#10827) Fixes #10812 This PR removes `mockAsyncRedwoodDirective` from documentation and properly show how to test async directives using `resolves` and `rejects`. History: mockAsyncRedwoodDirective was an early implementation but after PR review it was determined that a separate functions wasn't needed, but the resolves/rejects could be uses by making mockRedwoodDirective handle promises better. However, the documentation retained the older reference. --------- Co-authored-by: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com>
…ains how to test async directives (#10827) Fixes #10812 This PR removes `mockAsyncRedwoodDirective` from documentation and properly show how to test async directives using `resolves` and `rejects`. History: mockAsyncRedwoodDirective was an early implementation but after PR review it was determined that a separate functions wasn't needed, but the resolves/rejects could be uses by making mockRedwoodDirective handle promises better. However, the documentation retained the older reference. --------- Co-authored-by: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com>
Summary and description
The Directive documentation says to use
mockAsyncRedwoodDirective
to test for asynchronous directives.As it does not seem to exist, and according to the
mockRedwoodDirective
docstring, I should use it instead.redwood/packages/testing/src/api/directive.ts
Lines 32 to 68 in dda2a7c
Also, this docstring does not show how to test async validator directives, what I found to be quite troublesome.
From experimentation, I came up with this PoC to test for these.
test.ts
test.test.ts
I hope this can help if anyone else has troubles with testing async validator directives and that the documentation gets clarified.
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: