plover-testing

Diagnose and fix Vitest, better-sqlite3, and Electron test failures in the Plover repo.

1|Updated May 24, 2026
One-click install
npx skills add https://github.com/tryplover/Plover --skill plover-testing-tryplover
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: plover-testing
Source: https://github.com/tryplover/Plover/tree/main/.claude/skills/plover-testing
Command: npx skills add https://github.com/tryplover/Plover --skill plover-testing-tryplover

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and running Vitest tests in this Electron repo hits recurring, confusing failures: vi.mock hoisting errors, native-module ABI mismatches after pnpm dev, SQLite foreign-key fixture errors, and pre-existing renderer test failures that look like regressions. This Skill maps each symptom to its root cause and fix. ## Core Features & Use Cases - Mocking and lint fixes: Resolve vi.mock hoisting ReferenceErrors with vi.hoisted, clear EventEmitter listeners correctly, and satisfy noUncheckedIndexedAccess plus no-non-null-assertion with destructure patterns. - Native module and fixture triage: Fix better-sqlite3/keytar ABI mismatches between Electron and Node, EPERM file-lock rebuild failures on Windows, and FOREIGN KEY constraint errors by seeding parent goal and task rows. - Use Case: After a pnpm dev session, roughly 132 tests suddenly fail at new Database(':memory:'). The Skill identifies the Electron-vs-Node ABI mismatch and directs you to run root pnpm test, which rebuilds the native modules first. ## Quick Start Ask the AI to diagnose why your Vitest run is failing in this repo and apply the matching fix from the symptom table.

Frequently Asked Questions about plover-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix 'Cannot access before initialization' with vi.mock in Vitest?▼

vi.mock is hoisted above outer variable declarations, so plain const or let mock variables are undefined when the mock factory runs. Declare mock variables with vi.hoisted(...) so they initialize before any hoisted vi.mock blocks execute.

Why do better-sqlite3 tests fail after running pnpm dev in Electron?▼

pnpm dev rebuilds better-sqlite3 for Electron's ABI, but Vitest runs under plain Node with a different ABI, so the native module constructor throws. Run pnpm --filter ./app rebuild better-sqlite3 keytar, or use root pnpm test which rebuilds automatically.

How do I fix FOREIGN KEY constraint failed when inserting test rows in SQLite?▼

The summaries.task_id column is a real foreign key referencing tasks(id), and SQLite foreign keys are enabled in migrations. Seed the parent goal via GoalsRepo.create and the task via TasksRepo.create before inserting a summary with a non-null taskId.

Can I launch an Electron app from a Bash or PowerShell tool for visual verification?▼

No. Sandboxed shell subprocesses have no interactive window station, so Electron exits silently without creating a BrowserWindow or logging anything. Verify UI changes with typecheck, lint, tests, and diff review, or ask the user to run pnpm dev themselves.

Why does pnpm test fail with EPERM unlinking better_sqlite3.node on Windows?▼

A running pnpm dev Electron session holds the native binary file open, and Windows cannot delete a dlopen'd file, so node-gyp's clean step fails. Close the electron.exe and node.exe processes, with the user's consent, before rerunning pnpm test.

How do I satisfy no-non-null-assertion ESLint rule in TypeScript tests?▼

With noUncheckedIndexedAccess enabled, result[0] is possibly undefined and the non-null assertion operator is banned by ESLint. Destructure the array and use optional chaining, such as const [r0] = result; expect(r0?.kind).toBe(...), which fails the assertion identically when undefined.