[英]Jest testing module.exports instead of export default of a class that extends
Trying to test module.exports that equals a createReactClass. 试图测试等于createReactClass的module.exports。 I have only tested components that export default of a class.
我只测试了导出类默认值的组件。
I have tried to approach it the way I have with the export default but no Joy on it. 我试图按照我的方式处理它的导出默认值,但没有喜欢它。
//myfile.jsx
module.exports = createReactClass({ some additional content here })
//myfile.spec.jsx
let createReactClass = require("../myfile")
let props = {
Hello: "hello"
};
it('testing', (done) => {
const component = shallow(<createReactClass {...props}/>);
});
The above test is not rendering what I expect. 上述测试没有呈现我的期望。 It is
它是
No errors just not rendering the component 没有错误只是没有渲染组件
Minor issue it seems. 似乎是小问题。 Capitalize
C
as CreateReactClass
because react thinks its normal html tag but its not so not rendered. 将
C
大写为CreateReactClass
因为react认为它是正常的html标记,但它不会被渲染。 https://reactjs.org/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized https://reactjs.org/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.