javascript - Testing socket.io with Zombie.js across two browsers -


i'm building real time chat app using node , socket.io. having problems trying feature test using zombie. app working fine in browser test failing message

assertionerror: expected '' include 'hello' 

during debugging seems when zombie presses send button not fire 'chat message' event - though in development.

describe('chat feature', function() {      beforeeach(function(done) {      browser1 = new browser({        site: "http://localhost:3000"      });      browser2 = new browser({        site: "http://localhost:3000"      });      done();    });      beforeeach(function(done) {      browser1.visit('/', done);    });      beforeeach(function(done) {      browser2.visit('/', done);    });      describe("chat page has been rendered", function() {      beforeeach(function(done) {        browser2.pressbutton('javascript testing');        browser2.fill('.chatbox-input', 'hello');        browser2.pressbutton('send', done);      });      it('sends chat messages between browsers', function(done) {        expect(browser1.text('li')).to.contain('hello');        done();      });    });  });

and html (dynamically loading scripts content div using jquery)

<html>    <head>    <title>global code network</title>    <link rel='stylesheet' href='/stylesheets/style.css' />  </head>    <body>      <div class="main">      <h1>global code network</h1>      <div id="content"></div>    </div>      <div class="bottom-bar">      <h2>current requests:</h2>      <div id="join-rooms"></div>    </div>      <script id="chat-template" type="text/template">      <ul id="messages"></ul>      <form id="chatbox" action="">        <input type="text" class="chatbox-input" id="m" name="chat-input" autocomplete="off" />        <input type="submit" value="send"></input>      </form>    </script>    <script id="end-chat-template" type="text/template"></script>    <script src="/socket.io/socket.io.js"></script>    <script src="http://code.jquery.com/jquery-1.11.1.js"></script>    <script src="/scripts/main.js"></script>  </body>  </html>

client side js

(function(exports) {      var socket = io();        socket.on('person joined', function(data) {      $('.bottom-bar').remove();      $('#content').html($('#chat-template').html());      $('#chatbox').submit(function(e) {        e.preventdefault();        socket.emit('chat message', {          roomid: data.roomid,          message: $('#m').val()        });        $('#m').val('');      });      socket.on('chat message', function(data) {        $('#messages').append($('<li>').text(data.message));      });    });      exports.socket = socket;    })(this);

and server side js

io.on('connection', function(socket) {    socket.on('join room', function(data) {      socket.join(data.roomid);      io.to(data.roomid).emit('person joined', {        roomid: data.roomid      });        socket.broadcast.emit('update available rooms', {        rooms: rooms      });    });      socket.on('chat message', function(data) {      io.to(data.roomid).emit('chat message', data);    });  });

thanks


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -