反应测试库+开玩笑。如何做基本快照?

时间:2020-09-30 14:21:56

标签: reactjs unit-testing snapshot react-testing-library

我正在尝试从酶切法转换。 而使用react-testing-library运行快照会使我对现有快照之类的怪异更改

-  className="flex"
+  class="flex"

or

-     <Sidebar
+     <sidebar

这是我的基本测试。有人有什么想法吗?

  jest.mock('./sidebar.js', () => 'Sidebar');

  it('matches the saved snapshot', () => {
    let { container } = renderComponent();

    expect(container).toMatchSnapshot();
  });

  const renderComponent = ({ children = '{{children}}', ...rest } = {}) => render(
    <Layout {...rest}>{children}</Layout>
  );

谢谢!

0 个答案:

没有答案