我正在尝试测试我的 SpringComponent。该组件使用反应弹簧 https://www.react-spring.io/用于动画。当我运行测试时,出现以下错误:
“玩笑遇到了意想不到的令牌”。
如果我评论我的 Spring 代码,错误就会消失并且我的测试通过。
这是测试代码:
import React from "react";
import SpringComponent from "../components/SpringComponent";
test('renders without crashing', () => {
expect(true).toBeTruthy();
});
SpringComponent 代码:
import React from "react";
import {Spring} from "react-spring/renderprops-universal";
class SpringComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
content: this.props.content,
}
}
componentDidUpdate(prevProps) {
}
render() {
let content = this.state.content;
console.log("content: " + content);
return <div>
<Spring
from={{opacity: 0}}
to={{opacity: 1}}
>
{props => <div style={props}>
{content}
</div>}
</Spring>
</div>
}
}
export default SpringComponent;
我想知道我必须做什么来测试这段代码。我应该嘲笑什么吗?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)