innerText is undefined in jest test

后端 未结 1 1243
栀梦
栀梦 2021-01-07 19:11

When testing using jest I saw that the property innerText is undefined while not in test it has the right value.

  it(\'get text from div\', ()          


        
相关标签:
1条回答
  • 2021-01-07 20:06

    If you are using the default testEnvironment, then you are using jsdom.

    You can check this issue to see why it is not implemented in jsdom : https://github.com/tmpvar/jsdom/issues/1245

    The primary issue is the fact that innerText leans on the layout engine for guidance, and jsdom has no layout engine

    If you want "full" browser support you can check puppeteer

    0 讨论(0)
提交回复
热议问题