Skip to content

Commit

Permalink
docs(*): 📝 Readme tests info update
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocalazans committed Jul 20, 2022
1 parent 1f23bf1 commit 4bd6e4a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Expand Up @@ -166,6 +166,25 @@ exports.handler = useInjection(createAction, {

The Twilio Serverless structure make it hard for testing sometimes. So this provides a method that works perfectly with useInjection ready functions. The `useMock` act like useInjection but mocking some required fragments as `getAssets` and `getFunctions`.

>
```
Your files structures must be as:
| /root
| - package.json
| - src
| -- functions
| -- assets|
or:
| /root
| - package.json
| - functions
| - assets
```

Exports your function:

```js
Expand All @@ -174,13 +193,13 @@ async function functionToBeTested(event) {
return Response(something)
}

exports.handler = useInjection(functionToBeTested, {
const handler = useInjection(functionToBeTested, {
providers: {
myCustomProvider,
},
});

module.exports = { functionToBeTested }; // <--
module.exports = { functionToBeTested, handler }; // <--
```

You always need to import the twilio.mock for Response Twilio Global object on your testing files begining. **(Required)**
Expand Down

0 comments on commit 4bd6e4a

Please sign in to comment.