Skip to content

Commit 6dba78e

Browse files
authored
test(fmdapi): add mock infrastructure for unit tests (#102)
- Create capture script for recording live API responses - Add mock-fetch utility for mocking global fetch in tests - Reorganize tests: move E2E tests to tests/e2e/ - Create mock-based unit tests that don't require live FM server - Update vitest config to exclude E2E tests by default - Add test:e2e and capture scripts to package.json Co-Authored-By: Claude Opus 4.5 <[email protected]> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Builds a robust test setup that decouples unit tests from a live FileMaker server and isolates E2E tests. > > - **Mock infra**: Add `tests/utils/mock-fetch.ts`, `tests/fixtures/responses.ts` (captured FM responses), and `tests/utils/mock-server-url.ts`; refactor unit tests to stub global `fetch` and use `mockResponses` > - **Capture script**: New `scripts/capture-responses.ts` to hit a live server, sanitize URLs, and regenerate `tests/fixtures/responses.ts` > - **Test reorg**: Move live tests to `tests/e2e/**` and add new E2E specs; convert existing `client-methods.test.ts` to pure unit tests using mocks > - **Config/scripts**: Update `package.json` with `test:e2e` and `capture` commands and simplify `test`; adjust `vitest.config.ts` to exclude `tests/e2e/**` by default > - Minor test cleanups: consistent imports (`../src/index`), afterEach `vi.unstubAllGlobals()`, and small assertion/name fixes > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit beec7bf. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 0ea1146 commit 6dba78e

File tree

11 files changed

+1706
-208
lines changed

11 files changed

+1706
-208
lines changed

packages/fmdapi/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"format": "biome format --write .",
4545
"dev": "tsc --watch",
4646
"ci": "pnpm build && pnpm check-format && pnpm publint --strict && pnpm test",
47-
"test": "doppler run -- vitest run",
47+
"test": "vitest run",
48+
"test:e2e": "doppler run -- vitest run tests/e2e",
49+
"capture": "doppler run -- npx tsx scripts/capture-responses.ts",
4850
"typecheck": "tsc --noEmit",
4951
"changeset": "changeset",
5052
"release": "pnpm build && changeset publish --access public",

0 commit comments

Comments
 (0)