Skip to main content

Explain the concept of stub in NodeJS

In Node.js, stubs are basically the programs or functions that are used for stimulating the module or component behavior. During any test cases, stubs provide the canned answers of the functions

Features of Stub:

  • Stubs can be either anonymous.
  • Stubs can be wrapped into existing functions. When we wrap a stub into the existing function the original function is not called.
  • Stubs are functions or programs that affect the behavior of components or modules.
  • Stubs are dummy objects for testing.
  • Stubs implement a pre-programmed response.