Skip to content

Commit ba7a81b

Browse files
authored
test: improve code coverage to 91% (#17)
- Configure @vitest/coverage-v8 with coverage reporting (pnpm test:coverage) - Add unit tests for previously untested modules: token-storage, csv, index, program - Add comprehensive tests for command modules: members, records, auth (login OAuth flow), apps, custom-fields, permissions, prices, tables - Cover error handlers, optional fields, branch conditions, and edge cases across all modules - Update ARCHITECTURE.md and AGENTS.md to document new test files and coverage tooling - Statements: ~62% → 91.5%, Branches: ~44% → 74%, Tests: 169 → 307 --------- Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
1 parent 5a4fe9b commit ba7a81b

18 files changed

Lines changed: 2346 additions & 22 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ yarn-error.log*
2121
*.tsbuildinfo
2222
next-env.d.ts
2323

24+
# coverage
25+
/coverage
26+
2427
# local docs
2528
/docs

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This file provides guidance to AI agents when working with code in this reposito
88
pnpm build # Build CLI with tsup (output: dist/)
99
pnpm dev # Run CLI from source via tsx (e.g. pnpm dev -- members list)
1010
pnpm test # Run all tests with vitest
11+
pnpm test:coverage # Run tests with v8 coverage reporting
1112
pnpm check # Lint and format check (Biome via ultracite)
1213
pnpm fix # Auto-fix lint and format issues
1314
pnpm type-check # TypeScript type checking without emit

ARCHITECTURE.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **Project**: Memberstack CLI
44
> **Repository**: https://github.com/Flash-Brew-Digital/memberstack-cli
5-
> **Last updated**: 2026-02-17
5+
> **Last updated**: 2026-02-22
66
77
## Overview
88

@@ -57,16 +57,20 @@ memberstack-cli/
5757
│ │
5858
│ └── core/ # Core library tests
5959
│ ├── auth.test.ts
60+
│ ├── csv.test.ts
6061
│ ├── graphql-client.test.ts
62+
│ ├── index.test.ts
6163
│ ├── no-color.test.ts
6264
│ ├── oauth.test.ts
65+
│ ├── program.test.ts
6366
│ ├── program-options.test.ts
6467
│ ├── quiet.test.ts
68+
│ ├── token-storage.test.ts
6569
│ └── utils.test.ts
6670
6771
├── dist/ # Compiled output (ESM)
6872
├── tsup.config.ts # Bundler config (esbuild via tsup)
69-
├── vitest.config.ts # Test config (mockReset, restoreMocks)
73+
├── vitest.config.ts # Test config (mockReset, restoreMocks, v8 coverage)
7074
├── biome.jsonc # Linter/formatter (Biome via Ultracite)
7175
└── package.json # Node >=20, pnpm, type: module
7276
```
@@ -168,12 +172,12 @@ All user-facing output (tables, spinners, messages) goes to **stderr**. JSON out
168172
| `open` | Opens browser for OAuth login |
169173
| `papaparse` | CSV parsing and generation |
170174

171-
Dev: `tsup` (bundler), `tsx` (dev runner), `typescript`, `vitest` (tests), `biome` via `ultracite` (lint/format).
175+
Dev: `tsup` (bundler), `tsx` (dev runner), `typescript`, `vitest` (tests), `@vitest/coverage-v8` (coverage), `biome` via `ultracite` (lint/format).
172176

173177
## Build & CI
174178

175179
- **Build**: `tsup` compiles `src/index.ts` to ESM in `dist/`
176-
- **Test**: `vitest` with mocked GraphQL client and spinner, covers all commands and core libraries
180+
- **Test**: `vitest` with mocked GraphQL client and spinner, covers all commands and core libraries (`pnpm test:coverage` for v8 coverage report)
177181
- **Lint**: Biome via `ultracite` (`pnpm check` / `pnpm fix`)
178182
- **Type check**: `tsc --noEmit` (`pnpm type-check`)
179183
- **PR checks** (`.github/workflows/pr-checks.yml`): type-check, lint, build, test on Node 24

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"build": "tsup",
5252
"dev": "tsx src/index.ts",
5353
"test": "vitest run",
54+
"test:coverage": "vitest run --coverage",
5455
"type-check": "tsc --noEmit",
5556
"check": "ultracite check",
5657
"fix": "ultracite fix",
@@ -69,6 +70,7 @@
6970
"@biomejs/biome": "2.4.2",
7071
"@types/node": "^25.2.3",
7172
"@types/papaparse": "^5.5.2",
73+
"@vitest/coverage-v8": "^4.0.18",
7274
"lint-staged": "^16.2.7",
7375
"tsup": "^8.5.1",
7476
"tsx": "^4.21.0",

pnpm-lock.yaml

Lines changed: 144 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)