Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Maximilian Grundke
    I have an issue with angular-websocket
    when I mock the backend in my unit test, all the calls to expectSend result in errors, as the mocked backend does not get the calls to send somehow
    on a side note: in the readme, there is a call to $websocketBackend.mock(); which is non-existant
    ```$websocketBackend = {}
    beforeEach ->
        angular.mock.module('ngWebSocket', 'ngWebSocketMock')
        inject (_$websocketBackend_) ->
            $websocketBackend = _$websocketBackend_
    Maximilian Grundke
    this is the code I use to initialize the mock
    in a test, I use it like this:
        $websocketBackend.expectSend("""{"id": 1,.....}""")
    but this only leads to the following output:
    Error: Requests waiting to be flushed
    I am certain, that send is called by the tested module
    Maximilian Grundke
    for some context: I use karma + jasmine with both PhantomJS and Chrome
    Maximilian Grundke
    Please correct me if I'm wrong: $websocketBackend.send() is never fired, because $websocketMock.readyState is undefined, so the while-loop in $WebSocket.fireQueue() does not run with mocked WebSockets
    So, adding $MockWebSocket.prototype.readyState = 1; allows calling $MockWebSocket.prototype.send
    Maximilian Grundke
    the next issue is with $WebSocketBackend.flush(), in wich (pending.message === msg.message) seems to be (undefined === undefined) in my case, even though pendingSends and sendQueue do contain the sent and expected strings
    removing both .message works as expected in the tests (i.e. really compares expected and sent string)
    Maximilian Grundke
    is somebody actually reading this? ;-)
    PatrickJS [tipe.io]
    @Parnswir yeah sorry I’ve been busy
    Brian Topping
    hi, what's the fastest way to get an example running after checking out from git? would be cool to have a tl;dr for just running it.
    Brian Topping
    Oh, the demo talks to echo.websocket.org, nm
    PatrickJS [tipe.io]
    @briantopping yeah that’s a good idea. I need to update the repo with breaking api changes so it works for both angular1 and angular2
    Brian Topping
    @gdi2290 is angular2 worth using yet?
    PatrickJS [tipe.io]
    @briantopping for production not at all but for small toy/example apps to check it out it’s fun
    Brian Topping
    cool, thanks! :)
    Is there a bower packer for angular-websocket-mock, or is that only in npm?
    PatrickJS [tipe.io]
    @davetclark you should be able to get it when you bower install angular-websocket
    Nate Dudenhoeffer
    You asked for some feedback on the api, I just started using the library, and the api seems ok, but I am not crazy about the architecture of the main provider.
    What I want to do is decorate the _onMessageHandler, and it seems that has been made entirely private, so I really can't.
    In my use case, we have decided we will only send JSON and heartbeat messages in our app, so I would like to parse all data to JSON once, before calling my registered handlers.
    Henry Hz
    hi there, please, does it work with 3 way databinding as a firebase/meteor style ?
    Luke Browell
    @gdi2290 It's great that you're looking at this. So many of us are rolling our own with socket.io right now, that when your plans for socket.io integration land it will be a real selling point.
    PatrickJS [tipe.io]
    I'm planning on rebuilding this to work for both Angular1 and Angular2 with a way to easily support any other integrations
    WebSocket connection to 'ws://abc.com' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
    Guys, in the presentation of the WebsocketMock, there is a parenthesis missing:
    var $websocketBackend;
    beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock');
    Guys, I really have trouble creating tests.

    describe('Websocket', function () {

    //load module

    var $websocketBackend, createController;
    beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock'));

    beforeEach(inject(function ($websocketBackend) {
    $websocketBackend = $websocketBackend;
    $websocketBackend.expectSend({data: JSON.stringify({test: true})});


    beforeEach(inject(function ($injector) {
    // The $controller service is used to create instances of controllers
    var $service = $injector.get('$service');
    createController = function () {
    return $service('mzksWebsocket');

    it(’test1', function () {
    var mzksWebsocket = createController();
    //some test

    ->failed to instantiate module ngWebSocketMock due to:
    Error: [$injector:nomod] Module 'ngWebSocketMock' is not available! You either misspelled the module name or forgot to load it. If registering a module ensu
    I fixed it.
    Benoit LeBlanc
    Hi there, Is there a quick way to find out if your socket is connected?
    nevermind, looked in source for readyStates :smile:
    Benoit LeBlanc
    Is this library still bein maintained though?
    Diego Benjamín Aguilar Aguilar
    @beleblanc I guess AngularClass/angular-websocket@88b6e88
    Benoit LeBlanc
    Will there be a new npm package soon with the latest merge as it resolves an issue I was having with webpack
    Hi there, does anybody know about an angular2 version of websocket?
    It should be compatible, shouldn’t it?
    Antonio Troina
    Hi guys, a quick question: I'm missing what the autoApply function should do. After around 60 seconds I see in my console.log this message: "angular.js:26309 Uncaught ReferenceError: autoApply is not defined" and my front-end stops receiving messages from the websocket server... any idea?
    Hey all, I'm looking to bring this module into my project. My project is using requirejs. Anytime I require the module, it tries to require "ws" and fails which fails the whole page. I looked at the src and seems its trying to require in module, exports, angular and ws. Has anyone got around this issue?
    Harish Gadiya
    how we can use angular websocket with typesscript anguarljs2 with unit testing
    Hamed Nourhani
    hi must i use socket.io alongside angular to connect server socket or there is a builltin functionality with ng?
    Pulkit Agarwal
    This message was deleted