> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenderly.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Local Development and Testing

> Achieve faster iteration on Web3 Action code and write automated tests for your action functions using @tenderly/actions-test.

To facilitate local development of your [Web3 Action](/monitoring/web3-actions/introduction) code, you can use the **@tenderly/actions-test** package (contained in tenderly-actions). It exposes a Tenderly runtime, so you can execute and perhaps test your Web3 Action in your local environment.

Install the [**@tenderly/actions-test**](https://github.com/Tenderly/tenderly-actions/tree/main/packages/actions-test) package to test your Web3 Action functions locally.

```bash title="example" showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
yarn add --dev @tenderly/actions-test
```

<Note>
  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.
</Note>

You can use **@tenderly/actions-test** in two ways to support your development process:

* 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. Import `TestRuntime` 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. For details on the event types you can pass, see [functions, events, and triggers](/monitoring/web3-actions/references/functions-events-triggers).

### A working example

Check out the multisig wallet example and the way it uses **@tenderly/actions-test** to run the action function locally.

<Card title="Running the  action function locally" href="" />

### 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

```tsx title="example.tsx" showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
// File: src/web3-actions-local/run.ts
// web3-actions sources location: src/actions/awesomeActions.ts


/*
 * Running Web3 Actions code locally.
 * TestRuntime is a helper class that allows you to run the functions,
 * and set storage and secrets before running the function
 **/
const main = async () => {
  const testRuntime = new TestRuntime();

  testRuntime.context.secrets.put('multisig.DISCORD_URL', process.env.DISCORD_URL || '');

  await testRuntime.execute(everyDay, new TestPeriodicEvent());

  await testRuntime.execute(whenDappPosts, new TestWebhookEvent({ foo: 'bar' }));

  const te = new TestTransactionEvent();
  te.to = '0x1a22...';
  te.from = '0xc023...';

  await testRuntime.execute(onTxEvent, new TransactionEvent());
};

(async () => await main())();
```

#### Step 2: Extend scripts in package.json of the enclosing project.

You can add this script to your **package.json** file.

```diff title="example" showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
{
    ...
  "scripts": {
    ...
+   "local-w3a-run": "ts-node src/web3-actions-local/run.ts"
    ...
  }
  ...
}
```

#### Step 3: Run the script

```bash title="example" showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
yarn local-w3a-run
```
