Skip to main content

Testing

nque tests both the frontend and the Rust backend, co-locating tests with the code they cover.

Frontend — Vitest​

  • Framework: Vitest 4 with Testing Library (React + DOM + user-event) in a jsdom environment.
  • Test files use the *.spec.ts / *.spec.tsx naming convention and are co-located with the source file (e.g. src/store/show.spec.ts).
  • Vitest globals are enabled — describe, it, expect, and assert are available without importing.
  • Setup lives in src/test/setup.ts.
pnpm test # run once
pnpm test:watch # watch mode

Example: testing a pure *Impl slice helper without the store:

it("marks the show dirty when renaming", () => {
const next = renameShowImpl(show, "New title");
expect(next.isDirty).toBe(true);
});

Component tests use @testing-library/react and @testing-library/user-event.

Backend — Rust​

  • Unit tests live in #[cfg(test)] mod tests blocks next to the code.
  • Run them all from the repository root with cargo test.
  • The ocr crate's tests require the downloaded models; they guard the bundled-model pipeline and the native-vs-scanned detection heuristic.
  • The show crate tests cover construction, filtering, cue splitting, the file envelope, schema validation, and command helpers using temporary files.

Before committing​

Run the relevant suites and lint:

pnpm test
cargo test
npx eslint src/

CI and the Husky pre-commit hook enforce formatting and lint on staged files.