Full-stack testing with PhantomJS

We have now written unit tests for logic at the core of our application and integration tests for our server-side routes. We don't yet have any automated tests that cover our views and client-side scripts as our manual testing throughout the previous chapters did.

We can write unit tests for client-side scripts using Mocha. However, all of our current client-side scripts interact with the server, so aren't good candidates for unit testing. Our manual tests are really full-stack tests of our whole application, including the interaction between the server and the client.

In order to achieve this in an automated test, we will need to use some form of browser automation. PhantomJS is a headless browser with a JavaScript ...

Get Learning Node.js for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.