开玩笑 / JSDOM-分配给文档时,测试窗口中红色输出的页面



这是我的测试。当比较函数失败时,我将在输入框中添加一个类,因此我的测试期望类列表长度为2。

     describe('confirm password element', () => {
        it('adds a class to the input box when the text fails comparison check', () => {
        document.body.innerHTML =
        ' <form>' +
        '<input class="confirm-password">' + 
        ' </form>';
          const e = document.querySelector('.confirm-password').classList;
          // keypress event to trigger comparison function will be here.
          expect(e).toHaveLength(2);
        })
     })

但是,一旦我运行测试,我就会在测试终端窗口中获得输出页面和页面,其片段在下面。

ect]}, Symbol(wrapper): {Symbol(impl): [Circular]}, Symbol(location info): {"end": 32, "endTag": [Object], "start": 19, "startTag": [Object]}}, "previousSibling": null}, Symbol(wrapper): {Symbol(impl): [Circular]}, Symbol(location info): undefined}}, Symbol(wrapper): {Symbol(impl): [Circular]}, Symbol(location info): undefined}, "previousSibling": null}, Symbol(wrapper): {Symbol(impl): [Circular]}, Symbol(location info): undefined}, "tokens": ["confirm-password"]}}

当我以" const e"开头的第二行评论第二行时,这会停止文本输出。顺便说一句,尽管所有这些不需要的输出,但测试还是正确评估了。

您是否使用--verbose运行测试?该片段看起来不像是错误。这可能只是非常健谈的记录。

最新更新