使用Jest无法找到DOM项目

时间:2018-07-18 09:03:51

标签: reactjs jestjs enzyme

我是最近才开始使用Jest测试反应的人。预期下面的测试代码结果为true,而不是false

// Login.js

class Login extends Component {
  ...
  render() {
    ...
    return (
      <LoginForm
        ...
      />
    );
  }
}

export default withRouterAndConnect(
  state => ({
    ...
  }),
  { ... }
)(Login);


// Login.test.js

import React from "react";
import ReactDOM from "react-dom";
import { configure, shallow } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

import Login from "./components/module/Login";

configure({ adapter: new Adapter() });

describe("<Login />", () => {
  test("renders logo image", () => {
    const wrapper = shallow(<Login />);
    expect(wrapper.find('LoginForm').exist().toBe(true);
  });
});

0 个答案:

没有答案