Add integration tests with mock GitHub API server and recorded fixtures#574
Draft
Copilot wants to merge 3 commits into
Draft
Add integration tests with mock GitHub API server and recorded fixtures#574Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/timrogers/gh-migrate-project/sessions/0f587d22-1a57-4a36-83a9-7b90e84ff773 Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
- Record real API fixtures from gh-migrate-project-sandbox project #1026 - Create mock HTTP server that replays recorded GraphQL/REST responses - Write 29 integration tests covering export, import, and error handling - Tests run entirely offline using local mock server (no token needed) - Add Jest config, test scripts, and CI workflow job - All tests pass, lint clean, typecheck clean Agent-Logs-Url: https://github.com/timrogers/gh-migrate-project/sessions/547b51ff-f3f9-4e2d-b7df-4320441150f6 Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
timrogers
May 4, 2026 22:34
View session
There was a problem hiding this comment.
Pull request overview
Adds a Jest-based integration test suite for gh-migrate-project that runs the real CLI (export/import) against an in-process mock GitHub API server, replaying recorded fixtures so tests require no network access or secrets.
Changes:
- Introduce a
MockGitHubServerthat serves/meta+ routes GraphQL queries to recorded/synthetic fixture responses. - Add integration tests that spawn the CLI asynchronously against the mock server and assert export/import behavior.
- Add Jest + ts-jest ESM config, wire integration tests into CI, and update ignore/typecheck config to include tests.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Includes tests/ in TS compilation/typecheck scope. |
| tests/integration/mock-server.ts | New in-process HTTP server that replays REST/GraphQL fixtures. |
| tests/integration/commands.test.ts | New integration tests that spawn the CLI against the mock server. |
| tests/fixtures/graphql-responses.ts | Loads recorded fixture JSON and exports typed responses + synthetic import responses. |
| tests/fixtures/recorded-api-responses.json | Recorded GitHub API responses used by the mock server. |
| package.json | Adds Jest/ts-jest deps + test/test:integration scripts. |
| jest.config.ts | New Jest config for TS + ESM via ts-jest. |
| eslint.config.mjs | Ignores jest.config.ts and relaxes a test-only lint rule. |
| .gitignore | Ignores .test-output created by integration tests. |
| .github/workflows/ci.yml | Adds an integration_tests job and includes it in release gating. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/11 changed files
- Comments generated: 5
Comment on lines
+15
to
+17
| import { join } from 'path'; | ||
| import { MockGitHubServer } from './mock-server.js'; | ||
|
|
Comment on lines
+11
to
+14
| import { join } from 'path'; | ||
|
|
||
| const rawFixtures = JSON.parse( | ||
| readFileSync(join(__dirname, 'recorded-api-responses.json'), 'utf-8'), |
Comment on lines
+30
to
+52
| return new Promise((resolve) => { | ||
| const child = spawn(TSX_BIN, [CLI_ENTRY, ...args], { | ||
| env: { | ||
| ...process.env, | ||
| ...env, | ||
| NODE_NO_WARNINGS: '1', | ||
| }, | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }); | ||
|
|
||
| let stdout = ''; | ||
| let stderr = ''; | ||
|
|
||
| child.stdout.on('data', (data: Buffer) => { | ||
| stdout += data.toString(); | ||
| }); | ||
| child.stderr.on('data', (data: Buffer) => { | ||
| stderr += data.toString(); | ||
| }); | ||
|
|
||
| child.on('close', (code) => { | ||
| resolve({ stdout, stderr, exitCode: code ?? 1 }); | ||
| }); |
Comment on lines
+17
to
+18
| "test": "NODE_OPTIONS='--experimental-vm-modules' npx jest", | ||
| "test:integration": "NODE_OPTIONS='--experimental-vm-modules' npx jest --testPathPatterns=tests/integration" |
| return ORGANIZATION_ID_RESPONSE; | ||
| } | ||
|
|
||
| // Create project field (must be checked BEFORE createProjectV2 since the query contains that substring) |
Agent-Logs-Url: https://github.com/timrogers/gh-migrate-project/sessions/0875db99-9d6d-498a-851a-52b06c912299 Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements extensive integration tests for the export and import commands using recorded API fixtures and a local mock server — no network access or tokens required at test time.
Approach
Fixtures were recorded from the real
gh-migrate-project-sandboxproject #1026, then a lightweightMockGitHubServer(plainhttp.Server) replays those responses by routing on GraphQL query content. The CLI is spawned as an async child process pointing--base-urlat the mock server.Changes
tests/fixtures/recorded-api-responses.json— Real API responses captured from the sandbox orgtests/fixtures/graphql-responses.ts— Typed exports that load and re-export the recorded data + synthetic import-flow responsestests/integration/mock-server.ts— Routes REST (/meta) and GraphQL requests to fixture responses based on query content matchingtests/integration/commands.test.ts— 29 tests across export (14), import (12), and error handling (3)jest.config.ts/package.json— Jest 30 + ts-jest ESM config,npm run test:integrationscript.github/workflows/ci.yml—integration_testsjob added to CI (no secrets needed)Coverage