【发布时间】:2019-12-31 18:10:44
【问题描述】:
我有一份文件如下。
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p id="para">My first paragraph.</p>
</body>
</html>
我在我的 React 应用程序中使用以下代码
const fieldElement = document.getElementById(fieldError);
现在我如何在我的 React 测试用例场景中测试这个特定的行
it("should provide fieldElement for the id", async () => {
let fieldError = "para"
// Need to write test for document.getElemetById here
});
有人可以解释一下吗?
【问题讨论】:
标签: javascript reactjs react-native jestjs enzyme