Comments (4)
unfortunately you have to define on your own if you run it on node environment
from asteroid.
Can someone provide more information about this? I made a stack overflow question about the same issue: https://stackoverflow.com/questions/45684811/jest-referenceerror-is-not-defined
● 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
I get this same error when I run jest test:
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
Someone suggested this, but didn't work for me
const WebSocket = require('ws')
global.WebSocket= WebSocket
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
from asteroid.
As far as the undefined websocket issue goes: you should define your own websocket in the class constructor like this:
const asteroid = require('asteroid');
const WebSocket = require('ws');
const Connection = asteroid.createClass()
const portal = new Connection({
endpoint: 'ws://localhost:3000/websocket',
SocketConstructor: WebSocket // <-------------- HERE
})
I have also commented this on the stack overflow issue: https://stackoverflow.com/a/45697156/6573438
from asteroid.
@holmrenser what fixed it for me was actually installing your PR: #122
The changes to SocketConstructor weren't necessary for me.
ReferenceError: WebSocket is not defined
at Asteroid.init (node_modules/asteroid/lib/base-mixins/ddp.js:46:67)
which is caused by (I think) trying to access the global.WebSocket which Jest doesn't have
Your PR declares it, removing the need to search for it in the global
PS
@holmrenser would you like to update your answer on SO and I'll approve it?
from asteroid.
Related Issues (20)
- Methods resolve on `result` instead of `updated` event
- Is it possible to upload file using Asteroid
- User should logged out from app in other device when he reset password from any of his device
- loginWithPassword is not working in Meteor 1.4.3.1 HOT 1
- Wss connection problem while trying to connect by https HOT 5
- Questions about the state of Asteroid HOT 5
- Asteroid & Subscriptions HOT 5
- Stopping a (global?) Subscription? HOT 2
- Disconnecting from Remote Meteor App? HOT 2
- Asteroid Publication Security HOT 1
- loginWith('google') : Setting access_type offline
- when is v3 going to release? HOT 4
- is mondora/ddp.js the successor to asteroid? HOT 1
- asteroid.userId gives inconsistent returns HOT 1
- Changing endpoint dynamically. OR Re-instantiating asteroid object
- need client bundle
- Error 404 "Method login not found" HOT 2
- createUser should not send username or email in an object user.
- This project is abandoned HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asteroid.