mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-28 00:08:21 -05:00
* feat(claude): added rules * fix(copilot): chat loading; refactor(copilot): components, utils, hooks * fix(copilot): options selection strikethrough * fix(copilot): options render inside thinking * fix(copilot): checkpoints, user-input; improvement(code): colors * fix(copilot): scrolling, tool-call truncation, thinking ui * fix(copilot): tool call spacing and shimmer/actions on previous messages * improvement(copilot): queue * addressed comments
1.5 KiB
1.5 KiB
paths
| paths | ||
|---|---|---|
|
Testing Patterns
Use Vitest. Test files: feature.ts → feature.test.ts
Structure
/**
* @vitest-environment node
*/
import { databaseMock, loggerMock } from '@sim/testing'
import { describe, expect, it, vi } from 'vitest'
vi.mock('@sim/db', () => databaseMock)
vi.mock('@sim/logger', () => loggerMock)
import { myFunction } from '@/lib/feature'
describe('myFunction', () => {
beforeEach(() => vi.clearAllMocks())
it.concurrent('isolated tests run in parallel', () => { ... })
})
@sim/testing Package
Always prefer over local mocks.
| Category | Utilities |
|---|---|
| Mocks | loggerMock, databaseMock, setupGlobalFetchMock() |
| Factories | createSession(), createWorkflowRecord(), createBlock(), createExecutorContext() |
| Builders | WorkflowBuilder, ExecutionContextBuilder |
| Assertions | expectWorkflowAccessGranted(), expectBlockExecuted() |
Rules
@vitest-environment nodedirective at file topvi.mock()calls before importing mocked modules@sim/testingutilities over local mocksit.concurrentfor isolated tests (no shared mutable state)beforeEach(() => vi.clearAllMocks())to reset state
Hoisted Mocks
For mutable mock references:
const mockFn = vi.hoisted(() => vi.fn())
vi.mock('@/lib/module', () => ({ myFunction: mockFn }))
mockFn.mockResolvedValue({ data: 'test' })