Book Image

Node Web Development - Second Edition

By : David Herron
Book Image

Node Web Development - Second Edition

By: David Herron

Overview of this book

Table of Contents (17 chapters)
Node Web Development Second Edition
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Summary


In this concluding chapter, we've covered the basics of developing unit tests for a Node application. Unit testing is of course a large topic, but with this information you can take the steps required to improve your application quality.

Specifically we've covered:

  • Considerations for testing asynchronous code (what if the expected callback is never called?)

  • Using the assert module to implement quick test cases

  • The Vows test framework

  • Some questions about when to implement a mock object, and when not to do so

  • Creating a test database to hold test data

  • Separating the individual units to test in isolation from the rest of the application

  • Creating a mock data model, that can also be useful when prototyping the application

  • Testing route functions with all dependencies mocked out

  • Using test case failures to debug and improve the application

  • Making it easy to run the tests

For this to be a complete test suite, it has to do much more than what we've shown here, for example:

  • More tests for the Notes module...