[英]how to write jestunit testcases for aem react compoenent
When I have Code as below, how to write junit testcase for FiveGIntermediateEditConfig to cover.当我有如下代码时,如何为FiveGIntermediateEditConfig编写 junit 测试用例来覆盖。
const FiveGIntermediateEditConfig = {
emptyLabel: "FiveG Intermediate",
isEmpty() {
return true;
},
};
class FiveGIntermediateContainer extends Container {
render() {
return (
<div className="fiveGInter">
</div>
);
}
}
FiveGIntermediateContainer.defaultProps = {};
export default MapTo("vcg/components/soe-assisted/react/fiveGInter")(
compose(withRouter)(FiveGIntermediateContainer, FiveGIntermediateEditConfig)
);
JUnit is a Java framework so it won't be very useful in testing a React app. JUnit 是一个 Java 框架,因此它在测试 React 应用程序时不是很有用。 If you're looking for a JavaScript equivalent, consider https://jestjs.io/
如果您正在寻找 JavaScript 等价物,请考虑https://jestjs.io/
Plain Jest is fine for any JavaScript that isn't strictly react-specific. Plain Jest 适用于任何非严格反应特定的 JavaScript。
When it comes to React components, possible testing approaches are well-described in the React documentation: https://reactjs.org/docs/testing-recipes.html对于 React 组件,React 文档中详细描述了可能的测试方法: https://reactjs.org/docs/testing-recipes.html
Most tools described there are just utilities that you plug into a test runner like Jest.那里描述的大多数工具只是您插入到 Jest 等测试运行器中的实用程序。 Most, if not all examples, assume that Jest is used, but it's not a hard rule.
大多数(如果不是全部)示例都假设使用了 Jest,但这不是硬性规定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.