twilio-labs / serverless-toolkit

CLI tool to develop, debug and deploy Twilio Functions

Home Page:https://www.twilio.com/docs/labs/serverless-toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose runtime-handler dev Response class for testing purposes

philnash opened this issue · comments

When testing Twilio functions locally you need to construct a global scope that contains a Twilio object that has a Response property, as well as a global Response property, in order to match the environment that Functions run in. In the function-templates repo we achieve this with setup and teardown methods with a mocked and out of date Response class.

The Response class from the runtime-handler is still effectively a mock, as it is a development version of the real Response that the deployed Functions runtime-handler uses, but it is up to date with the version of the runtime-handler that is being used. If we exposed this class (and perhaps a GlobalTwilio object somehow) then function-templates and customers could use the Response object that matches their runtime-handler version in their tests.

(see also RUN-4441)