Javascript Jest测试无法运行,因为TypeError(hyperHTML问题?)

Javascript Jest测试无法运行,因为TypeError(hyperHTML问题?),javascript,unit-testing,testing,automated-tests,jestjs,Javascript,Unit Testing,Testing,Automated Tests,Jestjs,我在尝试单元测试时遇到了一个错误,我不确定它的原因是什么。 Jest测试将正常运行,直到我需要从文件中导入函数进行测试 这是我想要运行的jest测试的一个非常简化的版本,require导致了我遇到的bug //SigninView.test.js let SigninRouteHandler = require("../../../../../src/js/Modules/Portal/Signin/SigninView"); test('empty passing test', () =&g

我在尝试单元测试时遇到了一个错误,我不确定它的原因是什么。 Jest测试将正常运行,直到我需要从文件中导入函数进行测试

这是我想要运行的jest测试的一个非常简化的版本,require导致了我遇到的bug

//SigninView.test.js
let SigninRouteHandler = require("../../../../../src/js/Modules/Portal/Signin/SigninView");

test('empty passing test', () => {
    expect(true).toBe(true);
});
这是控制台的错误

$ jest js/ModulesTests/PortalTests/SigninTests/SigninView.test.js
FAIL  tests/js/ModulesTests/PortalTests/SigninTests/SigninView.test.js

● Test suite failed to run

TypeError: original.cloneNode is not a function

  121 | 
  122 |     render() {
> 123 |         return this.html`
      |                     ^
  124 |         <div class="parts-view-inner" onmouseup="${this.endDragging}">
  125 |             <div class="" id="sidebar-content-container" data-width=${this.state.sidebarWidth}>
  126 |                 ${CurrentBuildViewComponent}

  at setAttribute (node_modules/hyperhtml/cjs/objects/Updates.js:398:32)
  at Object.create (node_modules/hyperhtml/cjs/objects/Updates.js:70:22)
  at DocumentFragment.upgrade (node_modules/hyperhtml/cjs/hyper/render.js:44:27)
  at DocumentFragment.render (node_modules/hyperhtml/cjs/hyper/render.js:30:13)
  at PartsView.<anonymous> (node_modules/hyperhtml/cjs/hyper/wire.js:44:13)
  at PartsView.render (src/js/Modules/Parts/PartsView.js:123:21)
  at PartsView.value (node_modules/hyperhtml/cjs/classes/Component.js:102:36)
  at new PartsView (src/js/Modules/Parts/PartsView.js:35:14)
  at Object.<anonymous> (src/js/App.js:12:33)
  at Object.<anonymous> (src/js/Modules/Portal/Signin/SigninView.js:9:1)
  at Object.<anonymous> (tests/js/ModulesTests/PortalTests/SigninTests/SigninView.test.js:2:26)
$jest js/moduletests/PortalTests/SigninTests/SigninView.test.js
失败测试/js/moduletests/PortalTests/SigninTests/SigninView.test.js
● 测试套件无法运行
TypeError:original.cloneNode不是函数
121 | 
122 | render(){
>123 |返回this.html`
|                     ^
124 |         
125 |             
126 |${CurrentBuildViewComponent}
在setAttribute(node_modules/hyperhtml/cjs/objects/Updates.js:398:32)
在Object.create(node_modules/hyperhtml/cjs/objects/Updates.js:70:22)
在DocumentFragment.upgrade(node_modules/hyperhtml/cjs/hyper/render.js:44:27)
在DocumentFragment.render(node_modules/hyperhtml/cjs/hyper/render.js:30:13)
在PartsView(node_modules/hyperhtml/cjs/hyper/wire.js:44:13)
在PartsView.render(src/js/Modules/Parts/PartsView.js:123:21)
在PartsView.value(node_modules/hyperhtml/cjs/classes/Component.js:102:36)
在NewPartsView(src/js/Modules/Parts/PartsView.js:35:14)
at对象。(src/js/App.js:12:33)
at对象。(src/js/Modules/Portal/Signin/SigninView.js:9:1)
at对象。(tests/js/moduletests/PortalTests/SigninTests/SigninView.test.js:2:26)
正如您所看到的,它在hyperHTML文件中的某个点停止。也许这是一个问题

这是错误输出的代码

render() {
    return this.html`
    <div class="parts-view-inner" onmouseup="${this.endDragging}">
        <div class="" id="sidebar-content-container" data-width=${this.state.sidebarWidth}>
            ${CurrentBuildViewComponent}
            <div id="dragbarH" onmousedown="${this.handleHDrag}"></div>
            ${QuickSummaryViewComponent}
        </div>
        <div id="dragbarV" onmousedown="${this.handleVDrag}"></div>
        ${PartsExplorerViewComponent}
    </div>
    `;
}
render(){
返回this.html`
${CurrentBuildViewComponent}
${QuickSummaryViewComponent}
${PartsExplorerViewComponent}
`;
}
我可以使用jest fine运行单元测试,唯一遇到问题的时候是当我尝试导入其他类似的文件时。
如果您有任何见解,我们将不胜感激!谢谢您

您的
SigninView
组件在测试外部使用时工作正常?是的。只有在我们尝试开玩笑测试时才会抛出此错误。我们也在尝试摩卡咖啡,但我们仍然无法找出问题所在。