I am trying to start using react-testing-library on my project. Problem is, I can't setup everything properly.
Steps I made:
- I installed @testing-library/react and jest-dom as documentation suggests.
-
I setup jest.config.js:
module.exports = { setupFilesAfterEnv: [ '@testing-library/react/cleanup-after-each', ], }; -
I wrote basic test:
import React from 'react'; import App from '../App'; import {render } from "@testing-library/react"; it('renders without crashing', () => { const {asFragment} = render(<App/>); expect(asFragment).toMatchSnapshot(); });
Error I get:
4 |
5 | it('renders without crashing', () => {
> 6 | const {asFragment} = render(<App/>);
| ^
7 | expect(asFragment).toMatchSnapshot();
8 | });
9 |
My packages versions from package.json file:
"@testing-library/react": "^8.0.4",
"jest-dom": "^3.5.0",
"jest": "^24.8.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
I've tried several things like cleanuping locally not from jest.config.js file to make it work, but nothing seems to work.
Aucun commentaire:
Enregistrer un commentaire