Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Testing utility docs #11805
Testing utility docs #11805
Changes from 2 commits
2dc6ff8
13f215f
307ec68
911ec00
74a4624
e21f71d
4bb20df
0407a13
68db1bd
aebc3a5
3baf29d
cdef3da
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Small observation: this first sentence feels like we're about to show you how to integrate all 3 libraries together, but I see you've split this up by "jest and testing library" and "jest and MSW". Should this reflect that sentiment a bit? Are they mutually exclusive?
Alternatively, we could consider framing this around the utility you're using on the fetch side of things. In the first section, the tests are really about mocking fetch itself, while I assume the MSW section will be about setting up a mock server to intercept network requests (which would use the real fetch). Would it make sense to have those sections titled as such? Perhaps "Testing by mocking fetch" and "Testing with MSW" or something to that effect?
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.
One more note, you might consider switching around the last two sentences:
Having that as the last sentence feels like it sets up the code you're about to see a bit better.
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 reworded this a bit in one of the latest commits, lmk what you think!
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.
Could this be considered a
<Tip>
?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.
Would it make sense to split up this code block a bit to introduce each of these in pieces? It might make this setup a bit more digestable and allow you to add a bit of explanation for each part of the setup.
For example, the redux docs start with "create a resuable render function", then move to some of the smaller pieces required for the test setup in their own code blocks, finally followed by the test example itself.
Feel free to ignore this if you feel this is already the best way to present this information.
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 really like this idea, I'll implement this in a bit.
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.
Would it make sense to also include a section about "When to use
createSchemaFetch
vs MSW"? Since these utilities are mutually exclusive, it might be best to state that somewhere explicitly in this doc to ensure those that aren't as familiar with those tools don't get confused and try and use both together.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.
Really, really love this idea :) Will work on adding that shortly.
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.
Added in aebc3a5 let me know what you think!
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 LOVE the content you have in here. There is a ton of really great stuff.
Stepping back a bit, I wonder if we should tweak the order on how we introduce the changes with
using
. The examples above work with the assumption thatusing
is available in your environment, then this section takes a step back and essentially says "whoa, you might not have this available, so here is what you do if not".Instead, I'd start with the assumption that our useres don't have
using
available by updating the exmaples above to use plainconst
with therestore
function, then make this section a "if you're using TS 5.2 or greater, check out this great thing you can do to make cleanup even easier!".I think you can do this with minimal changes to this section. I'd keep a lot of the content in here as-is.
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.
This seemed to render sorta weird, I think because of the way the docs add the external link icon. Do you know by chance if there is any way to avoid this?
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.
Hah yeah I just noticed this on another page. Will look into whether we can remove the link icon here 👍