Skip to content

feat(runtime-handler): export Response class for testing#552

Open
wittyreference wants to merge 1 commit intotwilio-labs:mainfrom
wittyreference:feat/export-response-class
Open

feat(runtime-handler): export Response class for testing#552
wittyreference wants to merge 1 commit intotwilio-labs:mainfrom
wittyreference:feat/export-response-class

Conversation

@wittyreference
Copy link
Copy Markdown

Summary

Export the Response class from @twilio/runtime-handler so it can be used in unit tests without custom mocks.

Closes #384

Problem

Every developer testing Twilio Functions must create their own mock Response class because the real implementation is internal to the runtime-handler package. The package's index.ts was literally // placeholder and the main entry threw on import.

Solution

  • Export Response from src/index.ts
  • Update package.json main/types to point to the real index
  • Add ./testing subpath export for explicit test usage
  • Update test to verify the export works

Usage

const { Response } = require('@twilio/runtime-handler');
// or
const { Response } = require('@twilio/runtime-handler/testing');

Testing

All 52 test suites pass (410 tests). The runtime-handler.test.ts now verifies the export works with method presence checks.

Export the Response class from the package root, enabling unit testing of
Twilio Functions without custom mock implementations.

Previously, the main entry point was a placeholder that threw on import.
Now require('@twilio/runtime-handler') returns { Response }, providing
the same class used by the local dev server with full method support
(setStatusCode, setBody, appendHeader, setCookie, etc).

Closes twilio-labs#384
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: c0704b2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@twilio/runtime-handler Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose runtime-handler dev Response class for testing purposes

1 participant