Commit 6dba78e
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- packages/fmdapi
- scripts
- tests
- e2e
- fixtures
- utils
11 files changed
+1706
-208
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
0 commit comments