HomeBytesheetsRoadmapsUI TemplatesUI ToolsStack Discussion
2 Topics
Chapter•10 Minutes

Databases & Testing

Database selection and unit-testing doubles in Node.js applications.

Q78: How do you choose between relational databases and MongoDB in Node.js?

Use SQL (e.g., PostgreSQL) for strict ACID compliance, fixed schemas, and complex relations. Use MongoDB for flexible document structures, rapid prototyping, and horizontal scalability.

Key Takeaways
  • SQL offers strict relational consistency and structured schema guarantees.
  • NoSQL offers flexible document schemas and easier horizontal scaling.
Knowledge Check

Which object mapping library is commonly paired with MongoDB in Node.js applications?

Q79: What is the difference between mocks and stubs in Node.js unit testing?

Stubs provide canned responses to method calls made during tests without recording call assertions. Mocks are pre-programmed with expectations regarding calls they should receive.

Key Takeaways
  • Stubs return static predefined data during test execution.
  • Mocks verify specific behavioral interaction expectations.
Knowledge Check

Which test double type asserts whether a specific method was invoked with particular arguments?