Skip to main content
Testing pieces is optional but recommended for complex logic. Pieces can be tested using Vitest with the createMockActionContext helper from the framework. For a full working example, see the text-helper piece tests on GitHub.

Setup

1. Add vitest to your piece

Add vitest as a dev dependency in your piece’s package.json and add a test script:

2. Create a vitest config

Create vitest.config.ts in your piece root:

3. Write tests

Create a test/ directory and add .test.ts files:

4. Run tests