【发布时间】:2019-05-12 14:32:27
【问题描述】:
我有这个容器
import React from "react";
class App extends React.Component {
render() {
return (
<div className="App">
<input type="text" onChange={this.changeInput} />
<button onClick={this.addItem}>Add</button>
</div>
);
}
}
export default App;
为什么我不能在上面使用shallow?我的测试看起来像这样
import App from "./index";
describe("App", function() {
it("should render", function() {
const wrapper = shallow(<App />);
//expect(wrapper).toBe(1);
});
});
错误提示 Enzyme expects an adapter to be configured, but found none. 但我相信我已经正确设置了 Enzyme。我想测试 App 是否包含输入和按钮,但我卡在那里..
【问题讨论】:
标签: reactjs ecmascript-6 jestjs enzyme