mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
32ac8e73fd
* Fix Biome lint violations and add Biome CI check Biome was not configured to respect .gitignore, so ~92% of the 13,355 reported diagnostics came from gitignored build artifacts. Enable VCS integration (useIgnoreFile), apply safe auto-fixes across the repo, fix the remaining mechanical errors by hand, downgrade judgment-call a11y / dangerouslySetInnerHTML rules to warnings, and add a 'biome ci' job to the Lint workflow so violations block PRs going forward. * Use an empty changeset (no behavior change, no release needed)
@workflow/vitest-workbench
This workbench demonstrates how to test workflows with Vitest using the @workflow/vitest plugin.
How It Works
- Vitest Plugin: The
workflow()plugin from@workflow/vitesthandles SWC transforms, bundle building, and in-process handler registration automatically. - No Server Required: Workflows execute entirely in-process using a Local World instance — no HTTP server needed.
- Tests: Use
start(workflow, args)and awaitrun.returnValue, plus helpers likewaitForSleep()andwaitForHook().
Usage
pnpm test
Project Structure
workbench/vitest/
├── workflows/
│ ├── simple.ts # Basic workflow with arithmetic steps
│ ├── sleeping.ts # Workflows with sleep() calls
│ ├── hooks.ts # Workflow with createHook() for external data
│ └── webhook.ts # Workflow with createWebhook() for HTTP payloads
├── test/
│ └── workflow.test.ts # Integration tests for all workflow types
├── vitest.config.ts # Vitest config with workflow() plugin
├── MOCKING.md # Analysis of mocking limitations
└── package.json
Test Coverage
- Simple workflow: Start and await return value
- Sleep workflow:
waitForSleep()→wakeUp()to skip sleep - Multi-sleep workflow: Targeted
wakeUp()with correlation IDs - Hook workflow:
waitForHook()→resumeHook()with approval/rejection - Webhook workflow:
waitForHook()→resumeWebhook()with Request payload