Embedded Stubs

In this module, you’ll learn how to use embedded stubs to make low-level infrastructure Nullable. You’ll add an embedded stub to HttpClient, an infrastructure wrapper for HTTP-based services.

Concepts

Download the slides and transcript here.

Direct links to patterns discussed in this module:

Primers

You may wish to familiarize yourself with these primers before starting on the exercises:

Exercise Setup

Start with the Overall Setup. Then:

1. Check out the code

  1. Check out the exercise branch:
    • JavaScript: git checkout embedded-stubs-js
    • TypeScript: git checkout embedded-stubs-ts
  2. Create a custom branch for your changes:
    • git checkout -b my-embedded-stubs

2. Prepare to start working

  1. Open the exercise files:
    • src/node_modules/http/_http_client_test.js (or .ts)
    • src/node_modules/http/http_client.js (or .ts)
  2. Run the build watcher from the root of the repository:
    • Windows: .\watch.cmd quick
    • Mac/Linux: ./watch.sh quick
  3. Confirm that the build runs and ends with BUILD OK.

Exercises

The course is designed to have more exercises than you can finish in a single session, so don’t worry about finishing everything. Instead, work at your own pace and focus on understanding the material. If you get to the end of challenge #4, you’ll have covered the most important information.

  1. Challenge #1: Injecting the Stub
  2. Challenge #2: Stubbing Behavior
  3. Challenge #3: Default Response
  4. Challenge #4: Configurable Responses
  5. Challenge #5: Configurable Endpoints
  6. Challenge #6: Normalization
  7. Challenge #7: Partial Configuration
  8. Challenge #8: Infinite Responses
  9. Challenge #9: Distinct Responses
  10. Challenge #10: Exceptional Responses
  11. Challenge #11: Output Tracking
  12. Bonus Challenges

Start with Challenge #1

Return to course overview