-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Docgen: replace assertions for getIntermediateRepresentation
unit tests with snapshots
#31547
Docgen: replace assertions for getIntermediateRepresentation
unit tests with snapshots
#31547
Conversation
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.
Looks good and tests pass 👍
I might be missing some context or rationale, but I'd love to get a second opinion on whether this is a good (and common in Gutenberg) use case for inline snapshot testing. FWIW I can definitely see value in it and how it reduces the manual part of maintaining these tests, which is why I am inclined to agree to move forward here.
Absolutely. In fact, we discussed also measuring the time that those tests take before and after this PR — I am planning on posting that data later today |
…ts with snapshots
I did a little experiment to understand if there's a difference in execution speed when using inline snapshots.
Results
Although this is by no means a comprehensive analysis, these first results seem to show that there isn't a loss in performance when running tests with inline snapshots. View detailsOn
On this branch (with inline snapshots):
|
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.
Nice, thank you for working on this PR 👍🏻
Description
Replace all the assertions in the
getIntermediateRepresentation
unit tests with equivalent snapshot checks.This approach requires less developer maintenance while serving the same purpose as the previous hand-written assertions.
How has this been tested?
npm run test-unit packages/docgen
Screenshots
N/A
Types of changes
Refactor
Checklist:
*.native.js
files for terms that need renaming or removal).