jdx / mean-sample

Sample project for Write Modern Web Apps with the MEAN Stack by Jeff Dickey
https://mean-sample.herokuapp.com
166 stars 90 forks source link

CH10, assertion always failing #47

Open marchage opened 8 years ago

marchage commented 8 years ago

Hello,

I am getting the following error:

AssertionError: expected '@dickeyxxx my new post0.6566946622915566' to include 'my new post0.5507085409481078'

'@dickeyxxx my new post0.6566946622915566' is the forlast addition to the posts and 'my new post0.5507085409481078' is the latest testrun. I use web sockets to update the posts list. What I am doing wrong? It seams to always compare the forlast with the last addition to the posts list

Thanks in advance.

tjkemper commented 8 years ago

@marchage

In the file /ng/websockets.js change the port to 3001

In server.js, the following line was added: var port = process.env.PORT || 3000; And in protractor.conf.js we specify the port to be 3001: onPrepare: function(){ process.env.PORT = 3001; require('./server') }

So when you run a protractor test, node listens to 3001, but our WebSocket logic is still looking for 3000.

Look at page 140 for a solution that does not require hard coding a port.

Essentially the solution is to alter the line where you declare url in file /ng/websockets.js var url = "ws://" + window.location.host;