在React中找到td的值

问题描述 投票:-1回答:1

我正在使用酶开发React上的Test,并且我想达到这个“ 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]
}

如何从该对象中提取值?在哪里可以找到有关此类对象的更多信息?

reactjs testing enzyme
1个回答
0
投票
所以最后我通过使用函数解决了

wrapper.containsMatchingElement(<td>{value}</td>).toBeTruthy;

© www.soinside.com 2019 - 2024. All rights reserved.