react-qrcode-logo
react-qrcode-logo copied to clipboard
How can we test this component rendering?
We are trying to write the tests for the component where we are using this. Although while running the test we are getting the error
The code we are writing to run the test is
describe("AuthQR component", () => {
it("should render the component", () => {
render(<AuthQR />);
});
});
AuthQR
is our component in which the QR Component using this library is being rendered. The code for the component goes like this
<QRCode
value="something"
size={250}
ecLevel="L"
bgColor="#FFFFFF"
fgColor="#212636"
id="aut-qr-code"
/>
While running the test We are encountering the error as follows
Cannot read properties of null (reading 'scale')
TypeError: Cannot read properties of null (reading 'scale')
at QRCode.Object.<anonymous>.QRCode.update (/Users/bhushan/Documents/my-web/apps/web/node_modules/react-qrcode-logo/dist/index.js:162:13)
at QRCode.Object.<anonymous>.QRCode.componentDidMount (/Users/bhushan/Documents/my-web/apps/web/node_modules/react-qrcode-logo/dist/index.js:145:14)
at commitLayoutEffectOnFiber (/Users/bhushan/Documents/my-web/apps/web/node_modules/react-dom/cjs/react-dom.development.js:23310:28)
Can you please tell me what I am doing wrong?
Jest doesn't support canvas natively, maybe try this SO solution?