在 React 中找到 td 的值



我正在使用酶开发 Test on 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;

最新更新