使用Vue测试工具测试具有socket.io依赖关系的Vue js组件

时间:2020-07-08 09:13:48

标签: unit-testing socket.io vue-component chai vue-test-utils

如何测试具有socket.io-client依赖性的vue组件? 在浏览器中,该组件已正确连接到服务器,但是当我将其安装在单元测试中时

  viewer = shallowMount(MyComponent,{
                propsData: testPropsData, 
            });
我从套接字

收到connection_error
 Error: xhr poll error
at XHR.Transport.onError (/home/ubuntu/projects/client/node_modules/engine.io-client/lib/transport.js:68:13)
at Request.<anonymous> (/home/ubuntu/projects/client/node_modules/engine.io-client/lib/transports/polling-xhr.js:132:10)
at Request.Emitter.emit (/home/ubuntu/projects/client/node_modules/component-emitter/index.js:145:20)
at Request.onError (/home/ubuntu/projects/client/node_modules/engine.io-client/lib/transports/polling-xhr.js:314:8)
at Timeout._onTimeout (/home/ubuntu/projects/client/node_modules/engine.io-client/lib/transports/polling-xhr.js:261:18)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10) type: 'TransportError', description: 503 }

我该如何解决?

0 个答案:

没有答案