Skip to Content
Learn
Model Testing Patterns
Review

You have developed a model using TDD!

  • The model layer represents entities and interactions in a web app’s problem domain.
  • Model paths can be test-driven using validators. Call validateSync and make assertions on the properties of [instance].errors.[path].
  • The storage of data can be tested with construction and updating methods like save and update. Retrieval can be tested with query methods like find, findOne, and findby.
  • Static methods are stored in [schema].statics and instance methods are stored in [schema].methods. Both can be tested like any other JavaScript function.

To learn more about Mongoose, read the guide and refer to the API docs as needed.

Folder Icon

Sign up to start coding

Already have an account?