how to check the actual DOM node using react enzyme

后端 未结 6 489
孤街浪徒
孤街浪徒 2020-12-20 11:29

Is there a way to get the actual DOM node so I can the query it with the Dom api as opposed to being required to use enzyme\'s api, it\'s just for edge cases where for examp

6条回答
  •  情深已故
    2020-12-20 12:09

    If you create a DOM using jsdom, something like this:

    import jsdom from 'jsdom';
    const doc = jsdom.jsdom('');
    global.document = doc;
    global.window = doc.defaultView;
    

    Then you can use enzyme's mount() to render whatever you wish to test.

    You can then assert against the style you are looking for:

    expect(wrapper).to.have.style("display", "none");

提交回复
热议问题