我是最近才开始使用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);
});
});