react-testing-library - 如何在 setup.test.js 中结合酶和反应测试库的配置
问题描述
我们的项目同时具有enzyme
和testing-library
。我的目标是将getByTestId覆盖到我的自定义中。但是,当我将第二个配置添加到我的 setup.test.js 时,一些测试会因Found multiple elements with the text
.
setup.test.js:
const { configure } = require("enzyme");
const Adapter = require("enzyme-adapter-react-16");
import { configure as conf } from "@testing-library/react";
window.__config = {};
conf({ testIdAttribute: "data-my-test-id" });
configure({ adapter: new Adapter() });
我的版本:
“酶”:“^3.11.0”,
"@testing-library/react": "^11.0.4",
解决方案
推荐阅读
- python - 命令冷却忽略用户
- python - 将字节存储在文本文件中
- android - Esri Native Xamarin Android 上的对象已拥有异常
- c# - 文件上传时丢失身份验证
- javascript - 一次激活一个主菜单隐藏其他主菜单
- powershell - 使用 VSTS REST API 创建带有标题的版本
- ajax - Yii2 ActiveForm Ajax Validation and submit
- java - 使用 IntelliJ 开发 Eclipse RCP
- fabricjs - FabricJS 使用画布缩放调整过滤器大小
- c++ - 具有经常更改优先级的作业的优先级队列的数据结构