Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
除了render使用“遍历库 Cheerio”..
render
我刚刚用mount's替换了我所有的render's,它的工作原理是一样的。 他们看起来和我很像。
mount
我应该选择什么?这两者的API在某种程度上是不相同的吗? 什么时候使用renderover有什么特别的建议mount?
渲染不需要全局 DOM 可用。因此,它允许测试在浏览器等环境之外运行。在您的情况下,如果您的测试用例在看起来您正在浏览器中运行测试之前正在运行(因为 mount 工作)并且您不需要使用渲染。但是,如果您的测试因为没有可用的全局 DOM 而失败,那么 render 可能是一个很好的解决方案
http://airbnb.io/enzyme/docs/api/render.html
Mount 是 FullDom 渲染。查看官方文档以获取示例。据我了解,如果您想测试诸如 componentDidMount 之类的生命周期事件,您应该使用 mount。
文档:http ://airbnb.io/enzyme/docs/api/mount.html