Home / Companies / Rollbar / Blog / Post Details
Content Deep Dive

Async node.js API server testing

Blog post from Rollbar

Post Details
Company
Date Published
Author
-
Word Count
1,429
Language
English
Hacker News Points
-
Summary

Rollbar's experience in building a robust test suite for their API server highlights the importance of thorough testing in preventing deployment issues for high-traffic applications. The team chose Vows over the popular Mocha framework for its alignment with familiar coding syntax and less reliance on special-case methods, despite Mocha's widespread use and features. The testing approach emphasizes the importance of separating view logic from API business logic, using callbacks in all functions to simplify future refactoring, and adopting asynchronous programming patterns. The process involves directly testing the API library and utilizing child processes to simulate server behavior, complemented by Vows macros and contexts for reusable tests. Rollbar faced challenges with maintaining real database testing without mock objects, opting to use a SQL fixture updated with schema changes. Continuous integration with CircleCI was employed to streamline the testing process, leveraging pre-installed systems to simulate a production environment closely.