-
Notifications
You must be signed in to change notification settings - Fork 10.3k
feat(gatsby-plugin-sharp): Add tracedSVG option in fluid and fixed processors #11981
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-plugin-sharp): Add tracedSVG option in fluid and fixed processors #11981
Conversation
Mind adding some tests for it? It's good enough to just test if traceSVG is ran with the correct values. And not ran if it's not needed ^^ You also need to run They aren't breaking so good to go 👍 |
Oups sorry didn't pay attention to tests. I also kind of avoided duplicate code from my first commit. i am not sure though if it is explicit enough. or maybe a better function name. let me know |
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 great overall! Requested a small change in a test assertion 🙂
args, | ||
}) | ||
|
||
expect(result.tracedSVG).toBeUndefined() |
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'd add a jest mock for the traceSVG
function (it's already exported) and add an assertion that it's not called. What do 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.
Any way i could mock this properly?
thought about
const spy = jest.spyOn(rest, `traceSVG`)
beforeEach(() => {
spy.mockClear()
})
afterAll(() => {
spy.mockClear()
})
with rest
const {
base64,
fluid,
fixed,
queueImageResizing,
getImageSize,
...rest
} = require(`../`)
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 seems trickier than I initially thought
Guess we should merge and iterate on the tests and the code (to make it easier to test) later
Published in [email protected] |
This is a follow-up on #11981 which addresses the following issue: when user asks for tracedSVG sharp also calculates base64 image. This leads to longer build times and when using gatsby-image the base64 gets loaded before the tracedSVG. Updated the unit-test that now shows that base64 should be undefined. let me know if you think i could improve this.
Fix: #11912