Skip to content

how to contribute testing

Douwe de Vries edited this page Jul 1, 2026 · 1 revision

Testing

CSV Anonymizer has tests at the frontend, Tauri command, Rust core, script, package, and release-check layers. Use scoped checks while developing, then run the broader gate described in Development workflow.

Canonical root checks

Command What it covers
npm run test Contract check, frontend Vitest suite, frontend production build, and cargo test --workspace
npm run lint Frontend ESLint, frontend build, and Rust clippy with -D warnings
npm run typecheck Frontend build and cargo check --workspace
npm run fmt cargo fmt --all --check
npm run deadcode:required Knip frontend scans and required cargo-machete unused dependency scan
npm run docs:check Verifies documented npm run commands in README.md and docs/*.md exist in package.json

Frontend unit tests

Vitest tests live beside the React and TypeScript code under frontend/src, for example frontend/src/App.test.tsx, frontend/src/hooks/useAnonymizerWorkflow.test.tsx, and frontend/src/components/ColumnTable.test.tsx.

npm run frontend:test
npm run frontend:typecheck
npm run frontend:lint

The frontend test environment is configured in frontend/vite.config.ts with jsdom and frontend/src/test/setup.ts.

Playwright e2e and accessibility

Browser workflow tests live in frontend/e2e/workflow.spec.ts. The Playwright config in frontend/playwright.config.ts starts Vite at http://127.0.0.1:5173.

cd frontend && npx playwright install chromium
npm run frontend:e2e
npm run frontend:a11y

The e2e command excludes tests tagged @a11y; the accessibility command runs the @a11y subset.

Rust tests

Rust unit and integration-style tests live close to their modules:

  • crates/csv-anonymizer-core/src/detection/tests
  • crates/csv-anonymizer-core/src/csv_io/tests.rs
  • crates/csv-anonymizer-core/src/direct_input/tests.rs
  • crates/csv-anonymizer-core/src/service/tests
  • src-tauri/src module tests
  • crates/csv-anonymizer-app/src CLI tests

Useful scoped commands:

cargo test -p csv-anonymizer-core
cargo test -p csv-anonymizer-tauri
cargo test -p csv-anonymizer-app
cargo test --workspace
cargo clippy --workspace --all-targets -- -D warnings

Detector changes should update fixture-backed tests, especially the taxonomy, validator, privacy, and multilingual matrix coverage under crates/csv-anonymizer-core/src/detection/tests.

Contract checks

scripts/check-contracts.mjs compares selected Rust enums and structs in crates/csv-anonymizer-core/src/types.rs against TypeScript unions and interfaces in frontend/src/types.ts.

npm run contracts:check

Run this whenever DTOs, Tauri command payloads, privacy report fields, release readiness fields, or direct-input result shapes change.

Smoke tests

scripts/rust-smoke.mjs builds or uses the CLI harness and verifies that fixture email values are removed from the generated output.

node scripts/rust-smoke.mjs

Set CSV_ANONYMIZER_BINARY only when you intentionally want to smoke-test an existing binary path.

Audits and dependency scans

npm run frontend:audit
npm run cargo:audit
npm run cargo:audit:required
npm run cargo:machete
npm run cargo:machete:required

The local cargo:audit and cargo:machete wrappers skip when tools are missing unless the required flag, CI, or the matching CSV_ANONYMIZER_REQUIRE_* environment variable makes them mandatory.

Packaging and release checks

npm run release:check
npm run tauri:prebuilt:check
npm run artifacts:rust:check
npm run linux:package-manager:check

Linux package-manager validation builds Tauri Linux artifacts, validates .deb and .rpm metadata, checks the signed APT repository generator, and validates the APT installer script. It is best run on Linux or in CI.

Benchmarks

Benchmarks are in crates/csv-anonymizer-core/benches.

cargo bench -p csv-anonymizer-core --bench csv_streaming
cargo bench -p csv-anonymizer-core --bench direct_input_paste
cargo bench -p csv-anonymizer-core --bench detector_matrix -- --sample-size 10

Use them for performance-sensitive detector, streaming, or direct-input changes. They are not a substitute for correctness tests.

Clone this wiki locally