Describe the bug
When rendering the SVG component in a render function from testing-library/react, the SVG does not render and its onError function fires, saying:
TypeError: convert is not a function
at getNode (file:///Users/dramus/Sites/svg-test/node_modules/react-inlinesvg/src/modules/utils.ts:28:18)
Your minimal, reproducible example
Can't make sandbox cause it happens when running tests via command line
Steps to reproduce
Not quite sure how to put this into a sandbox since it happens when running a test via command line, but you can reproduce by creating a new, clean Vite React TS project, adding vitest and react testing library, and making a simple test to try and render it.
import SVG from 'react-inlinesvg'
import { render, screen } from '@testing-library/react'
describe('Svg', async () => {
it('renders in a test', async () => {
render(
<SVG
src="<svg>test</svg>"
onError={(e) => {
console.log(e)
}}
/>
)
await screen.findByText('test')
})
})
Expected behavior
Render the SVG the same as it does when not testing
How often does this bug happen?
Every time
Screenshots or Videos
Platform
Mac OS, Sanoma 14.2, M2 chip
react-inlinesvg version
4.1.0
TypeScript version
5.2.2
Build tool
Vite
Additional context
No response
Describe the bug
When rendering the
SVGcomponent in arenderfunction fromtesting-library/react, the SVG does not render and itsonErrorfunction fires, saying:Your minimal, reproducible example
Can't make sandbox cause it happens when running tests via command line
Steps to reproduce
Not quite sure how to put this into a sandbox since it happens when running a test via command line, but you can reproduce by creating a new, clean Vite React TS project, adding vitest and react testing library, and making a simple test to try and render it.
Expected behavior
Render the SVG the same as it does when not testing
How often does this bug happen?
Every time
Screenshots or Videos
Platform
Mac OS, Sanoma 14.2, M2 chip
react-inlinesvg version
4.1.0
TypeScript version
5.2.2
Build tool
Vite
Additional context
No response