Say No(de) to the Browser: Testing your Webapp Frontend Code Using Just Node

The reality of testing frontend code is dark. React and other modern frameworks now enable us to write unit tests that test each component separately. But what if I want to test components together? If I want full interactivity, including Ajax calls? Today, the only recourse is to do browser automation testing, which are considered painfully slow, difficult to write, and flaky.

Today, in 2017, we finally have enough tools in our belt to have an alternative to browser automation. This alternative enables us to simulate a browser inside Node, and run your frontend code fully under Node. Incredibly enough, this is not too difficult to do.

I will be covering:
– Unit, integration, and end to end tests today
– The drawbacks of the current methodology
– Simulating DOM and the browser
– Writing tests using this simulation
– Adding full interactivity and Ajax call mocking to these tests
– And, finally, a poem!