FAQ: Model Testing Patterns - Hooks

This community-built FAQ covers the “Hooks” exercise from the lesson “Model Testing Patterns”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn Testing for Web Development

FAQs on the exercise Hooks

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

It says:

  • make your tests expressive by writing them in four phases
  • make your tests isolated with setup and teardown phases
  • follow the red, green, refactor cycle

What were the 4 phases again? It is the
1.setup
2. exercise
3. verification
4. teardown?

IF so then isn’t the second bullet repetative since it’s part of the 1st bullet point? It makes me think that maybe there might be a different 4 phases being referenced in the first bullet?

I verified and you got it right, the four phases are indeed:

  1. Setup
  2. Exercise
  3. Verification
  4. Teardown

Teardown is not being implemented in each of the projects we are doing here, and this particular exercise focuses in step 5 on await mongoose.connection.db.dropDatabase();.

I am suspecting they just wanted to put emphasis on that “isolation of tests” with a second bullet and the connectAndDrop function. To me it made sense as being setup (.connect) and teardown (.connection.db.dropDatabase()), but I might just be finding a way to rationalize it :sweat_smile: