Testing javascript nodejs + socket.io backend server with Travis CI

I have got a small backend server in nodejs which is using socket.io to connect with client and on the other side is uses google api to delivery data.

Is there a good way to write tests and still use something like Travis CI?

In a local enviroment there is no problem with doing test with a fake user.

Yes, you have a couple options.

  • Write unit style tests against your JavaScript frontend with something like Karma or Yeti, both of which support Travis CI. This would involve mocking out the socket.io API in your frontend code with something like Sinon.
  • Borrow some concepts from Laika which uses PhantomJS to execute browser code against your app running in its own process. Laika is for testing client/server interactions similar to what you're doing.

In either case you probably want to mock out the google API while testing using Sinon or Nock.

Just answered a question using nock but was too sleepy to care to check the old date. =/

See if this answer can help you in any way about HTTP mocking with nock:

Simulate HTTP responses to test a node.js HTTP client