1

我正在使用带有 jest-dom 的 react-testing-library。它工作正常,但是当我尝试使用toBeInTheDocument它时会抛出错误TypeError: element.getRootNode is not a function

expect(getByText('Not in dom')).not.toBeInTheDocument(); // It works
expect(getByText('Value in DOM')).toBeInTheDocument();  // It throws the error

错误日志:

TypeError: element.getRootNode is not a function
      
      at Object.it (src/x/y/z.test.js:42:34)
          at new Promise (<anonymous>)
      at process._tickCallback (internal/process/next_tick.js:68:7)
4

0 回答 0