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

How can we test this component rendering? #29

Open
bhushan-patil-official opened this issue Aug 17, 2022 · 1 comment
Open

How can we test this component rendering? #29

bhushan-patil-official opened this issue Aug 17, 2022 · 1 comment

Comments

@bhushan-patil-official
Copy link

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?

@omarryhan
Copy link

Jest doesn't support canvas natively, maybe try this SO solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants