Codesandbox.io 中 React-Testing-Library 的问题 [英] Issue with React-Testing-Library in codesandbox.io

查看:40
本文介绍了Codesandbox.io 中 React-Testing-Library 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 React 的相对菜鸟.想在这个沙箱中练习一些 tdd 基本反应沙箱.似乎测试代码正在影响应用程序组件状态如果您在浏览器和测试之间切换,您会看到测试项被添加到列表中 - 即使我在测试中运行渲染和清理.

I am a relative noob to React. Wanted to practice some tdd in this sandbox basic react sandbox. It seems that the test code is affecting app component state If you switch between Browser and Tests you'll see test items being added to the list - even though i am running render and cleanup in the tests.

不确定我做错了什么?

推荐答案

Codesandbox 在运行测试时遇到一些问题.那是因为它们在浏览器中运行,而不是在单独的 jsdom 环境中.我建议您改为在您的机器上运行测试.

Codesandbox has some problems running the tests. That's because they run in the browser and not in a separate jsdom environment. I suggest you run the tests in your machine instead.

这篇关于Codesandbox.io 中 React-Testing-Library 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆