https://react-svgr.com/docs/jest/

social.jpg

Configure Jest to work properly with SVGR.

Create a mock file __mocks__/svg.js:

export const ReactComponent = 'div'

The above mock would support the following import syntaxes:

import logoURL from '../assets/logo.svg'import { ReactComponent as Logo } from '../assets/logo.svg'

2. Configure Jest

In your package.json

"jest": {"\\\\.svg": "<rootDir>/__mocks__/svg.js"

or in your jest.config.js

module.exports = {'\\\\.svg$': '<rootDir>/__mocks__/svg.js',

Your snapshots will include all properties on the icon components, so they will be tested.

Edit this page on GitHub