reactjs - 在 React 中查找 td 的值
问题描述
我正在使用酶开发 React 测试,我想达到这个“td”的值
<td className="myCell" key={String(x) + String(y)}>{value}</td>
但使用此代码:
ArrayAreaComponent.find("td").first().render()
我收到:
initialize {
'0': {
type: 'tag',
name: 'td',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: [Object: null prototype] { class: 'myCell' },
'x-attribsNamespace': [Object: null prototype] { class: undefined },
'x-attribsPrefix': [Object: null prototype] { class: undefined },
children: [ [Object] ],
parent: null,
prev: null,
next: null,
root: {
type: 'root',
name: 'root',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: [Object: null prototype] {},
'x-attribsNamespace': [Object: null prototype] {},
'x-attribsPrefix': [Object: null prototype] {},
children: [Array],
parent: null,
prev: null,
next: null
}
},
options: {
withDomLvl1: true,
normalizeWhitespace: false,
xml: false,
decodeEntities: true
},
length: 1,
_root: [Circular]
}
如何从该对象中提取值?我在哪里可以找到有关此类对象的更多信息?
解决方案
所以最后我通过使用函数解决了
wrapper.containsMatchingElement(<td>{value}</td>).toBeTruthy;
推荐阅读
- java - 基于java中的属性对具有arraylist作为值的映射进行排序
- mongodb - InvalidPipelineOperator MongoError:无法识别的表达式“$replaceAll”
- python - 通过 Powershell 作为 System32 创建任务
- python - 给出所需输入时如何结束while循环?
- c - 为什么 for 循环中的 strlen 变量没有获取数据类型?
- java - 在来电处于活动状态时打开扬声器不适用于 Android 10
- reactjs - CodePipeline + Beanstalk 连接拒绝 React + Express 应用程序
- python - 当没有种群成员遵守遗传算法中的约束时,如何处理它?
- bit-manipulation - 用于浮点数规范化和中断识别的位运算符
- flutter - Flutter TabController - 在任何特定的 tabitem 内推送屏幕