feat: add local testing support for workflows#478
Conversation
- createWorkflowJob: .trigger() executes body directly for local testing - createWorkflow: .trigger() calls mainJob.trigger() for local testing - Export WORKFLOW_TEST_ENV_KEY from @tailor-platform/sdk/test - Add workflow trigger test examples to testing template Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 1e38927 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This comment has been minimized.
This comment has been minimized.
Add documentation for testing workflows locally: - Job unit tests with .body() - Mocking dependent jobs with vi.spyOn() - Integration tests with .trigger() and WORKFLOW_TEST_ENV_KEY Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
| trigger: async (args) => { | ||
| return await config.mainJob.trigger(...([args] as unknown as [])); |
There was a problem hiding this comment.
🟡 options parameter with authInvoker is silently ignored in local testing
The new trigger implementation ignores the options parameter, which contains authInvoker for authentication context.
Click to expand
Interface declares options parameter
At workflow.ts:15-18:
trigger: (
args: Parameters<Job["trigger"]>[0],
options?: { authInvoker: AuthInvoker<string> },
) => Promise<string>;Implementation ignores it
At workflow.ts:40:
trigger: async (args) => { // 'options' not capturedImpact
If a user writes code like:
await workflow.trigger({ id: 1 }, { authInvoker: auth.invoker("admin") });In local testing, the authInvoker is silently ignored. In production (after bundler transformation), it's used by tailor.workflow.triggerWorkflow(). This behavioral difference could mask authentication-related bugs during local testing.
Was this helpful? React with 👍 or 👎 to provide feedback.
This comment has been minimized.
This comment has been minimized.
Update integration test example to use workflow.mainJob.trigger() instead of workflow.trigger() to get the actual result. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Metrics Report (packages/sdk)
Details | | main (e2c5e83) | #478 (55173b4) | +/- |
|--------------------|----------------|----------------|-------|
- | Coverage | 47.5% | 47.5% | -0.1% |
| Files | 182 | 182 | 0 |
| Lines | 5199 | 5202 | +3 |
+ | Covered | 2473 | 2474 | +1 |
| Code to Test Ratio | 1:0.3 | 1:0.3 | 0.0 |
| Code | 28822 | 28822 | 0 |
| Test | 9735 | 9735 | 0 |Code coverage of files in pull request scope (57.1% → 50.0%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
Summary
createWorkflowJob:.trigger()now executes body directly for local testingcreateWorkflow:.trigger()now callsmainJob.trigger()for local testingWORKFLOW_TEST_ENV_KEYfrom@tailor-platform/sdk/testfor env configurationUsage
Test plan
.body().trigger()🤖 Generated with Claude Code