Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Commit 860b5f1

Browse files
committed
feat(jest): add svgr support
1 parent c2868a3 commit 860b5f1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

__mock__/svgr-mock.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// https://react-svgr.com/docs/jest/
2+
import * as React from 'react';
3+
export default 'SvgrURL';
4+
const SvgrMock = React.forwardRef((props, ref) => <div ref={ref} {...props} />);
5+
export const ReactComponent = SvgrMock;

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module.exports = {
22
preset: 'ts-jest',
33
moduleNameMapper: {
44
'.+\\.(css|styl|less|sass|scss)$': `identity-obj-proxy`,
5-
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `<rootDir>/__mocks__/file-mock.js`,
5+
'.+\\.svg$': `<rootDir>/__mocks__/svgr-mock.js`,
6+
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `<rootDir>/__mocks__/file-mock.js`,
67
},
78
moduleDirectories: ['node_modules', 'src'],
89
testPathIgnorePatterns: ['node_modules', '.cache', 'public'],

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)