Skip to content

Releases: beyond-the-cloud-dev/http-mock-lib

v1.1.0

29 Jun 13:07
Compare
Choose a tag to compare

29-June-2025

This release introduces a major update to the HttpMock library, including breaking changes to the API and a powerful new feature for stacking mock responses.

✨ New Features

Response Stacking

You can now mock multiple responses for the same endpoint. The mock will return the responses in the order they were defined. This is useful for testing scenarios where an initial call might fail, and a subsequent call succeeds.

Example:

new HttpMock()
    .whenGetOn('/api/v1').statusCodeNotFound()
    .whenGetOn('/api/v1').statusCodeOk()
    .mock();

// First callout to /api/v1 will receive a 404 Not Found response.
HttpResponse response1 = new TestApi().makeCallout('GET', '/api/v1');

// Second callout to /api/v1 will receive a 200 OK response.
HttpResponse response2 = new TestApi().makeCallout('GET', '/api/v1');

💥 Breaking Changes

The primary method names for setting up mocks have been changed to improve clarity and readability. The on keyword has been added to the method names.

  • get() is now whenGetOn()
  • post() is now whenPostOn()
  • put() is now whenPutOn()
  • patch() is now whenPatchOn()
  • deletex() is now whenDeleteOn()
  • trace() is now whenTraceOn()
  • head() is now whenHeadOn()

Example:

Old:

new HttpMock().get('/api/v1').statusCodeOk().mock();

New:

new HttpMock().whenGetOn('/api/v1').statusCodeOk().mock();

📦 Other Changes

  • Updated copyright year to 2025.
  • Added assertion messages in test classes for better failure diagnosis.
  • Refactored internal implementation for improved maintainability.

v1.0.0

21 Oct 07:35
b646fc3
Compare
Choose a tag to compare

21-October-2024