Scenario testing is a process of first identifying how users, services, etc interact with your code, then writing tests based on these use cases. Scenario testing is a way to perform Behavior Driven Development tests, by storing all pertinent information of a given behavior inside of a single scenario object.

Maddox allows you to create generic scenarios based on how the code you are testing is executed. Maddox does this by exposing four different scenarios. These four different scenarios fall into two Scenario Categories, HTTP and Module.

Categories

  1. HTTP - Scenario to unit test an HTTP Request.
  2. Module - Scenario to unit test a module, function, or some section of your code.

Scenarios

  1. HttpRequestScenario - HTTP
  2. FromCallbackScenario - Module
  3. FromPromiseScenario - Module
  4. FromSynchronousScenario - Module

If you are testing a function in the controller layer of your service (one that takes two params req and res), then you can utilize the 'HttpRequestScenario'. If you are testing a function that returns a callback, a promise, or is synchronous, then you should use the 'FromCallbackScenario', 'FromPromiseScenario', 'FromSynchronousScenario' respectively.

To learn more about each individual scenario, please keep reading.