Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jest/JSDOM—分配给文档时测试窗口中红色输出的页面_Javascript_Unit Testing_Jestjs_Jsdom - Fatal编程技术网

Javascript Jest/JSDOM—分配给文档时测试窗口中红色输出的页面

Javascript Jest/JSDOM—分配给文档时测试窗口中红色输出的页面,javascript,unit-testing,jestjs,jsdom,Javascript,Unit Testing,Jestjs,Jsdom,这是我的测试。当比较函数失败时,我将向输入框添加一个类,因此我的测试预期类列表的长度为2 describe('confirm password element', () => { it('adds a class to the input box when the text fails comparison check', () => { document.body.innerHTML = ' <form>' +

这是我的测试。当比较函数失败时,我将向输入框添加一个类,因此我的测试预期类列表的长度为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);
        })
     })

当我注释掉以“const e”开头的最后第二行时,这将停止文本输出。顺便说一句,尽管有这些不必要的输出,测试还是正确地进行了评估

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

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"]}}