Jest referenceError 'is not defined'

Viewed 11574

I'm never calling WebSocket directly; it’s a dependency of Asteroid. Why is Jest failing to load it?

Also, this is supposed to be a default create-react-app test to check the App "renders without crashing". But the app loads fine even though the Jest test says it should crash.

My commit: https://github.com/Falieson/typescript-react-asteroid-meteor/commit/ab640bee540f1f2f5da2f0fe7b4be58f75b83d28#commitcomment-23644562

node scripts/test.js --env=jsdom --silent

Output:

 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
2 Answers
Related