我永远不会直接调用WebSocket,它是Asteroid的依赖。为什么Jest无法加载它? 此外,这应该是一个默认create-react-app
测试来检查应用程序“呈现没有崩溃”。但即使笑话测试说应该会崩溃,应用程序也会正常加载。Jest referenceError'is defined'
> node scripts/test.js --env=jsdom --silent
FAIL src/routes/App.test.tsx
● Test suite failed to run
ReferenceError: WebSocket is not defined
at Asteroid.init (node_modules/asteroid/lib/base-mixins/ddp.js:46:67)
at node_modules/asteroid/lib/asteroid.js:72:33
at Array.forEach (native)
at new Asteroid (node_modules/asteroid/lib/asteroid.js:70:16)
at Object.<anonymous> (src/config/asteroid.ts:6:16)
at Object.<anonymous> (src/routes/Login.tsx:14:18)
at Object.<anonymous> (src/routes/App.tsx:19:15)
at Object.<anonymous> (src/routes/App.test.tsx:5:13)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.915s
感谢所有帮助
谢谢,但没有解决问题 – Falieson