fix(build): added trigger.dev sdk mock to tests#2216
Merged
icecrasher321 merged 1 commit intostagingfrom Dec 5, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
icecrasher321
added a commit
that referenced
this pull request
Dec 5, 2025
Contributor
Greptile OverviewGreptile SummaryAdded mock for
The mock implementation covers the main API surface used throughout the codebase (background tasks, webhook processing, knowledge processing, etc.). Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Test as Test Suite
participant Vitest as Vitest Runtime
participant Mock as @trigger.dev/sdk Mock
participant Code as Application Code
Note over Test,Vitest: Test initialization
Test->>Vitest: Import vitest.setup.ts
Vitest->>Mock: Load SDK mock
Mock-->>Vitest: Mocked exports ready
Note over Test,Code: Test execution
Test->>Code: Import module under test
Code->>Mock: import { task } from '@trigger.dev/sdk'
Mock-->>Code: Return mocked task function
Code->>Mock: import { tasks } from '@trigger.dev/sdk'
Mock-->>Code: Return mocked tasks object
Code->>Mock: task({ id: 'example', run: fn })
Mock-->>Code: Return { trigger: vi.fn() }
Test->>Code: Execute test logic
Code->>Mock: tasks.trigger('id', payload)
Mock-->>Code: Resolve { id: 'mock-task-id' }
Code->>Mock: runs.retrieve('task-id')
Mock-->>Code: Resolve { id: 'mock-run-id', status: 'COMPLETED' }
Test->>Code: Assert behavior
Code-->>Test: Test passes
|
| })) | ||
|
|
||
| vi.mock('@trigger.dev/sdk', () => ({ | ||
| task: vi.fn(() => ({ trigger: vi.fn() })), |
Contributor
There was a problem hiding this comment.
style: The task mock doesn't match the real SDK structure. The actual task function returns an object with properties like id, retry, run, but this mock returns { trigger: vi.fn() }. This may cause issues if tests check task properties.
Suggested change
| task: vi.fn(() => ({ trigger: vi.fn() })), | |
| task: vi.fn((config) => ({ ...config, trigger: vi.fn() })), |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/vitest.setup.ts
Line: 93:93
Comment:
**style:** The `task` mock doesn't match the real SDK structure. The actual `task` function returns an object with properties like `id`, `retry`, `run`, but this mock returns `{ trigger: vi.fn() }`. This may cause issues if tests check task properties.
```suggestion
task: vi.fn((config) => ({ ...config, trigger: vi.fn() })),
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually
Checklist