所以,我试图使用
我结束了以下操作,它似乎可以正常工作,但是在返回值上调用“ .debug()”似乎非常可疑。.
import React from 'react';
import {render} from 'test-utils'; // THIS IS JUST A WRAPPER FOR @testing-library "render"
import renderer from 'react-test-renderer';
import {LoginPage} from '../LoginPage';
it('renders correctly', () => {
// CALLING debug() seems questionable. won't work without it.
const tree = renderer.create(render(<LoginPage />).debug()).toJSON();
expect(tree).toMatchSnapshot();
});