javascript - Jest referenceError 'is not defined' -
i'm never calling websocket directly, dependency of asteroid. why jest failing load it? also, supposed default create-react-app
test check app "renders without crashing". app loads fine though jest test says should crash.
> node scripts/test.js --env=jsdom --silent fail src/routes/app.test.tsx ● test suite failed run referenceerror: websocket not defined @ asteroid.init (node_modules/asteroid/lib/base-mixins/ddp.js:46:67) @ node_modules/asteroid/lib/asteroid.js:72:33 @ array.foreach (native) @ new asteroid (node_modules/asteroid/lib/asteroid.js:70:16) @ object.<anonymous> (src/config/asteroid.ts:6:16) @ object.<anonymous> (src/routes/login.tsx:14:18) @ object.<anonymous> (src/routes/app.tsx:19:15) @ object.<anonymous> (src/routes/app.test.tsx:5:13) @ <anonymous> @ process._tickcallback (internal/process/next_tick.js:188:7) test suites: 1 failed, 1 total tests: 0 total snapshots: 0 total time: 1.915s
thanks help
i have been bugged asteroid while before figured out can specify websocket want use in constructor so:
const asteroid = require('asteroid'); const websocket = require('ws'); const connection = asteroid.createclass() const portal = new connection({ endpoint: 'ws://localhost:3000/websocket', socketconstructor: websocket // <-------------- here })
Comments
Post a Comment