example
It’s recommended to keep tests and run scripts for web3-actions outside of the actions root
directory to avoid increasing the size of your Web3 Action project.
- Use it within your automated tests (recommended).
- Create a run script in JavaScript/TypeScript.
Using @tenderly/actions-test in your tests
To use @tenderly/actions-test in your tests, no additional steps are needed. ImportTestRuntime and events you need to test your Web3 Action and assert the results.
The following examples show how to use the package to invoke the Web3 Action and pass the event object the Action functions expect.
A working example
Check out the multisig wallet example and the way it uses @tenderly/actions-test to run the action function locally.Running the action function locally
Example: running an Action function within a script
The following example shows a file at src/web3-actions-local/run.ts that runs three actions, passing adequate events. Note the Web3 Actions source file (src/actions/awesomeActions.ts) is in a sibling to directory containing the script:
Step 1: write the run script
example.tsx
Step 2: Extend scripts in package.json of the enclosing project.
You can add this script to your package.json file.example
Step 3: Run the script
example