Recall & Review
beginner
What is the purpose of setting up a test database in Express applications?
A test database isolates test data from real data, ensuring tests run safely without affecting production or development data.
Click to reveal answer
beginner
Why do we teardown the test database after tests complete?
Teardown cleans up test data and resets the database state, preventing leftover data from affecting future tests.
Click to reveal answer
intermediate
Which Express testing lifecycle hooks are commonly used for database setup and teardown?
Hooks like beforeAll (or before) set up the database before tests, and afterAll (or after) clean it up after tests finish.
Click to reveal answer
intermediate
How can you ensure your test database is reset between individual test cases?
Use hooks like beforeEach and afterEach to reset or clear data between tests, keeping tests independent and reliable.
Click to reveal answer
beginner
What is a common tool or library used with Express to manage test database connections?
Libraries like Mongoose (for MongoDB) or Sequelize (for SQL) help manage connections and schema during test setup and teardown.
Click to reveal answer
Which hook is best to use for setting up a test database before all tests in Express?
✗ Incorrect
beforeAll runs once before all tests, making it ideal for initial database setup.
Why should test databases be separate from production databases?
✗ Incorrect
Separating test and production databases protects real data from accidental changes during testing.
What does teardown usually involve in test database management?
✗ Incorrect
Teardown cleans up test data to reset the database state after tests.
Which hook runs after each test to help reset the database state?
✗ Incorrect
afterEach runs after every test, useful for cleaning or resetting data between tests.
Which library is commonly used with Express for MongoDB test database management?
✗ Incorrect
Mongoose is a popular library to manage MongoDB connections and schemas in Express apps.
Explain the steps to set up and teardown a test database in an Express application.
Think about lifecycle hooks and data isolation.
You got /4 concepts.
Why is it important to reset the test database state between tests in Express?
Consider how leftover data might impact test results.
You got /4 concepts.