-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Be able to use with create-react-scripts #63
Comments
i do not know how to use |
I met this problem, too. I have a react app created by create-react-app contains some canvas element. Without this package I get somthing like this. // App.test.js
import React from 'react';
import { render } from '@testing-library/react';
import App from '../App';
describe('App', () => {
test('renders App component', () => {
render(<App />);
});
});
If I change jest setting in // package.json
{
...
"jest": {
"setupFiles": ["jest-canvas-mock"]
}
} import this package in Finally, I import it in each of the test files that were invoking canvas element like |
@wispamulet I have the same problem, despite import in each test file doesn't work for me. I try it like this:
But I still get a very similar error message as you did:
How did you import it? |
@Juuro it's been a while so I hope this would work 😯 // __test__/App.test.tsx
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { render, screen, RenderResult } from '@testing-library/react';
import 'jest-canvas-mock';
import App from '../App';
const setup = (): RenderResult =>
render(
<MemoryRouter>
<App />
</MemoryRouter>
);
describe('App', () => {
setup();
it('should ...', () => {
// do your job here
});
}); |
You can also do the import in your CRA app's |
It would be great to be able to use this with
create-react-app
The text was updated successfully, but these errors were encountered: