Testing firestore-cli

A layered strategy: deterministic tests first, real Firestore when it matters. The automatic gate needs no GCP credentials.

Three layers

Unit

pnpm test:unit

Fast checks for logic that never touches Firestore.

Blocking queue and AsyncGate behaviour, path validation, where-clause parsing, worker-pool behaviour, and printing.

Integration

pnpm test:integrated

The command surface against the Firestore emulator.

CRUD, merge semantics, recursive deletes, query-to-delete piping, and streaming a large JSONL file into set.

E2E smoke

pnpm test:e2e

The installed CLI, not the local repo build.

set, get, and delete against the emulator or a real project, with a trap that always cleans up and a real exit code.

Where it runs

Automatic CI gate

.github/workflows/ci.yml · Push to main and pull requests

  • Node 22 + Java 21: install, build, unit tests, then integration tests.
  • The Firestore emulator is cached so the jar is not re-downloaded.
  • A package-parity job compares the published bundle hash with the local build.

Real-GCP smoke

.github/workflows/e2e-real.yml · Manual, protected environment

  • Runs only on workflow_dispatch, behind the gcp-e2e environment and required reviewers.
  • Authenticates through Workload Identity Federation; no service-account keys.
  • Installs the published package and runs the smoke test against a dedicated project.

Conventions

  • Reseed before each integration case and clean up afterwards.
  • stdout carries data and document paths; status and spinner output stays on stderr.
  • Large reads use a 64 MB maxBuffer; the 481 MB fixture stays in LFS and out of CI.
  • Tests and fixtures are excluded from the published npm package.

Tradeoffs

  • Real-GCP coverage is protected and on-demand, not a prerequisite for merging.
  • There is no Docker path; GitHub Actions already provides clean, ephemeral runners.
  • Package parity covers built/main.mjs, not every file in the tarball.
  • The emulator cannot exercise IAM, network paths, or security rules; the real-GCP smoke test covers auth and project wiring.