-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby): update cache.set to resolve with set value #11327
feat(gatsby): update cache.set to resolve with set value #11327
Conversation
General Jest question after continuing to think of Jest best practices. For the code where I need the |
@mgmolisani yep! Just update with a new commit (as many as you want actually!). Come merge time, we'll just squash all those commits down into one nice, clean commit message :) |
@DSchau Updated with suggestions (sorry if this is basically just a duplicate notification). |
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.
There are few things that should be changed
Updated. Now resolves to (Also, as a git contributing noob, I didn't know that I should pull the official master branch into my topic branch to sync with the prod build. Caused a bunch of test failures. Is this something that is worth a pull request to the docs for?) |
Holy buckets, @mgmolisani — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Description
Cache set method will now resolve to the stored value. Both cache set and get now also reject on cache errors.
Also, I have never written Jest tests so this was a pretty exciting learning experience. Mocking was not very intuitive, especially due to the resolve function being in the callback of the get and set cache manager package. We also don't actually talk to the cache so the get tests feel a little wonky. Also, I do not know the shape of the error object sent from the cache manager or what actually can cause it so I mocked its existence with
!undefined
which is obviously justtrue
but I wanted it to read as something that was defined and not just true. Is there a better/conventional way to sayerr
is defined? Would{}
be a better solution? Interested if anyone has a better testing strategy than just forcing the error argument to exist or not.Related Issues
Addresses #11275