test: add runnable smoke tests for examples#46
Conversation
Add a Bun smoke test that discovers and executes every TypeScript example so examples fail CI when they drift from the public API. Make the batch-job example deterministic by injecting a test UserApi instead of performing a real network request during example execution. Document the examples smoke workflow and include a patch changeset.
Greptile SummaryAdds runnable smoke coverage for the
Confidence Score: 5/5Safe to merge — changes are additive test infrastructure with no impact on library behaviour. The diff adds a smoke test harness, a deterministic stub for one example, a new npm script, and a documentation line. No production code is modified, and the approach (per-file subprocesses, module-scope file discovery) is sound. test/examples-smoke.test.ts has two minor style points worth a quick look before merging.
|
| Filename | Overview |
|---|---|
| test/examples-smoke.test.ts | New smoke test file that discovers and runs each example as a subprocess; bare expect() outside a test block and .quiet() suppressing stderr are minor concerns |
| examples/batch-job.ts | Refactored to inject a stubbed UserApi dependency instead of making real network calls; deterministic and self-contained |
| package.json | Adds examples:smoke script pointing to the new test file |
| conventions/TESTING.md | Documents the new convention: examples must be deterministic, fast, and free of real network calls |
| .changeset/runnable-examples-smoke.md | Patch changeset entry for the smoke coverage addition |
Reviews (2): Last reviewed commit: "test: address example smoke review feedb..." | Re-trigger Greptile
Register one smoke test per TypeScript example so multiple failures are reported independently. Rename the batch-job example dependency provider from testUserApi to stubUserApi to better communicate that it is example stub wiring.
Summary
Closes #34.
Adds runnable smoke coverage for the examples directory so example drift is caught by the test suite and by the dedicated Bun script.
Changes
test/examples-smoke.test.ts, which discovers everyexamples/*.tsfile and registers one Bun smoke test per example for independent failure reporting.bun run examples:smokefor running the example smoke coverage directly.examples/batch-job.tsdeterministic by injecting aUserApidependency instead of performing real network calls during example execution.conventions/TESTING.md: examples must stay deterministic, fast, and free of real network calls.Verification
bun run examples:smokebun fmtbun lint:fixbun testbun typecheckbun lint