Skip to content

docs: README Testing example uses start: vi.fn() which does not match the Promise<void> contract #222

@untemps

Description

@untemps

Summary

The README "Testing" section shows a buildMockVocal helper where start: vi.fn() returns undefined. The real VocalInstance.start signature is (options?) => Promise<void>; the example fails the satisfies VocalInstance constraint under strict TypeScript and does not match the runtime contract useVocal relies on (it does await instance.start(options)).

Current state

```typescript
// README:543-562
const buildMockVocal = () => {
const handlers: Record<string, ((...args: unknown[]) => void)[]> = {}
return {
start: vi.fn(), // ← returns undefined, not Promise
stop: vi.fn(),
abort: vi.fn(),
cleanup: vi.fn(),
on: vi.fn(...),
off: vi.fn(),
get isRecording() { return false },
fire(...) { ... },
} satisfies VocalInstance & { fire: ... }
}
```

The satisfies constraint would error in strict TS because vi.fn() infers () => undefined, not () => Promise<void>.

Proposed improvement

Update the example so start returns a resolved promise that matches the real contract:

```typescript
start: vi.fn(async () => {}),
```

Or:

```typescript
start: vi.fn().mockResolvedValue(undefined),
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions