Skip to content
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

fix(gatsby-plugin-image): only log missing plugin error in development #32335

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -69,18 +69,20 @@ describe(`GatsbyImage browser`, () => {
jest.clearAllMocks()
global.SERVER = undefined
global.GATSBY___IMAGE = undefined
process.env.NODE_ENV = `test`
})

it(`shows a suggestion to switch to the new gatsby-image API when available`, async () => {
global.GATSBY___IMAGE = undefined
process.env.NODE_ENV = `development`

const { container } = render(
<GatsbyImage image={image} alt="Alt content" />
)

await waitFor(() => container.querySelector(`[data-placeholder-image=""]`))

expect(console.error).toBeCalledWith(
expect(console.warn).toBeCalledWith(
`[gatsby-plugin-image] You're missing out on some cool performance features. Please add "gatsby-plugin-image" to your gatsby-config.js`
)
})
Expand Down
Expand Up @@ -277,8 +277,8 @@ export const GatsbyImage: FunctionComponent<GatsbyImageProps> = function GatsbyI
return null
}

if (!gatsbyImageIsInstalled()) {
console.error(
if (!gatsbyImageIsInstalled() && process.env.NODE_ENV === `development`) {
console.warn(
`[gatsby-plugin-image] You're missing out on some cool performance features. Please add "gatsby-plugin-image" to your gatsby-config.js`
)
}
Expand Down