Open alx8437 opened 3 years ago
Still seeing this issue with the latest 11.0.2-canary.16
release
After upgrading nextjs from 9.4.0 → 9.5.6-canary.18 I'am now facing this issue. All my tests are failing and I believe something is wrong with the versions.
"resolutions": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2"
}
I'm having the same issue even after mocking next/image with:
jest.mock("next/image", () => { return () => <></>; });
This is still happening to me in 2022, any ideas?
2023 anyone? We are having this same issue has anyone managed to fix it?
What example does this report relate to?
jest testing
What version of Next.js are you using?
11
What version of Node.js are you using?
v12.18.2
What browser are you using?
Chrome
What operating system are you using?
lubuntu
How are you deploying your application?
next build
Describe the Bug
After replace an with an component from 'next/Image' tests snapshot aren't work. I think that it becouse of not read string 'import Image from 'next/image'' in my component. As a result, method 'create' from 'react-test-renderer' library is crash
Expected Behavior
Snapshot testing success
To Reproduce
Test is crash here
FAIL components/Main/tests/Main.test.tsx (6.244s) ● Snapshot тест
Code from test file
import React from 'react'; import renderer from 'react-test-renderer'; import Main from '../Main'; import { shallow } from 'enzyme';
const setUpShallow = (props?) => shallow(<Main {...props} />); const setUpSnapshot = (props?) => renderer.create(<Main {...props} />).toJSON();
it('Snapshot тест', () => { const component = setUpSnapshot(); expect(component).toMatchSnapshot(); });