Creating the product model

In the previous chapter, we learned all that we need to know about Mongoose, MongoDB, and Schemas. We are going to use that knowledge widely to build our Product schema and test it.

We do not want to leave the test till the very end, because sometimes, we tend to skip things that are left for the end. With the test-first approach, our tests will serve as guidelines for things to be implemented. We are going to use Mocha, which is very modular and supports multiple assertion libraries. For testing the models, we are going to use a BDD style assertion should.js (also developed for TJ). You can study all the possible assertions at https://github.com/tj/should.js.

Testing the products model

Now, create the product.model.spec.js ...

Get Web Application Development with MEAN 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.