Test Doubles

  • Dummy (Dummy Object)
    • doesn’t have any data inside
    • can be empty object {}
    • just exists
    • that’s the purpose of the Dummy Object
  • Fake
    • has simple data
      • contains simplified data of the object that is replaced by this fake object
      • example: using in-memory db or some “light” db (SQLite?) instead of real db on the project (like PostgreSQL, Oracle)
  • Stub
  • Spy (in testing)
  • Mock
    • it contains expectations about what parameters should be when the function will be called
      • if function was called with different parameters than expected parameters then test will be failed
  • Fixtures


  • For writing all this stuff you can use:
    • Functionality of the framework like JestJS
    • Independent library like Sinon.js

Subscribe to the newsletter

Get a once-per-week email with my latest content. By subscribing to this newsletter you will also be the first to receive last updates of my eBooks and courses.

0 members

Comments 💬