Skip to content

Run integration suite on node:test with real Probot 14 - #1097

Merged
decyjphr merged 6 commits into
yadhav/fix-recent-issuesfrom
decyjphr-integration-tests-node-test
Sep 30, 2026
Merged

decyjphr merged 6 commits into
yadhav/fix-recent-issuesfrom
decyjphr-integration-tests-node-test

Conversation

@decyjphr

@decyjphr decyjphr commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Probot 14 is ESM-only, so the Jest integration suite could no longer load it (SyntaxError: Unexpected token 'export') and all 7 suites failed before running a single test. This moves test/integration to node:test while keeping the unit suite on Jest. The integration tests were lightly coupled to Jest (hooks, assertions, Nock, real Probot instances), so the migration preserves the existing coverage instead of replacing it with simplified transport tests.

Approach

  • Async loading: loadInstance() dynamically imports probot, awaits probot.load(), and waits for the app's startup GET /app/installations call (from the un-awaited info()) so it cannot race with per-test scopes. createProbot gets env: {} so a developer's APP_ID / PRIVATE_KEY / GHE_HOST can't change credentials or base URL.
  • Nock preserved: fixtures and nock.disableNetConnect() are unchanged. Teardown asserts every expected request happened, listing pending mocks and any request-body mismatches, and always runs nock.cleanAll() / mock.restoreAll() for isolation.
  • Fail on unexpected errors: Probot gets a recording pino-compatible logger; any error/fatal log or console.error fails the test, including errors the app catches and logs. LOG_LEVEL echoes logs to stderr for debugging.
  • Body assertions: expect(body).toMatchObject(...) inside Nock matchers is replaced by a bodyMatching() helper with equivalent semantics.
  • Transport check: new transport.test.js verifies Nock intercepts the Probot Octokit fetch transport the app uses, and that unmocked requests are blocked.
  • CI: test:integration:ci (creates reports/, emits spec output plus JUnit to reports/integration-junit.xml) now runs in node-ci.yml on Node 22 and 24, and the JUnit report is uploaded as an artifact even on failure. Jest now ignores test/integration.
  • Separate compat fix: the repository test used yaml.safeLoad, removed in js-yaml v4; it now uses yaml.load (own commit).

Fixture updates

Once loading worked, fixtures no longer matched current app behavior. They now:

  • Send complete webhook payloads (owner login, organization, sender, installation); plugin tests use a deterministic repository.created trigger instead of a random one.
  • Serve org config from the admin repo (<org>/admin/.github/settings.yml) and mock the suborg lookup, repo-config directory, admin commit, and check-run requests the app now makes.
  • Match current Octokit endpoints (org-scoped team repo URLs, collaborator invitations, GET before PATCH on the repo).
  • Replace the stale "default branch not changed" repository.edited case with one asserting bot-generated edits are ignored.

Status and review notes

All 10 integration tests pass locally on Node 22; the unit suite (Jest), test:pagination, and lint on test/integration also pass. Node 24 is first exercised by this PR's CI run.

lib/proxyAwareProbotOctokit.js (used by handler.js) cannot be required with the installed ESM-only Octokit plugins, so it is not covered by the transport test. That is a separate, pre-existing issue.

decyjphr and others added 3 commits September 29, 2026 09:02
Probot 14 is ESM-only, so the Jest integration suite could not load it.
Move test/integration to node:test while keeping unit tests on Jest:

- loadInstance() is async, dynamically imports probot, awaits
  probot.load() and the app's startup /app/installations call.
- Keep nock fixtures and disabled net connect; teardown asserts all
  expected requests were made (listing pending mocks and body
  mismatches) and always cleans nock/mocks.
- Fail tests on error-level Probot logs and console.error calls.
- Replace expect().toMatchObject body checks with bodyMatching().
- Add transport.test.js proving nock intercepts the Probot Octokit
  fetch transport and blocks unmocked requests.
- Add test:integration:ci with a junit reporter; exclude
  test/integration from Jest.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ecyjphr-integration-tests-node-test

# Conflicts:
#	package.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The integration command remains red, and JUnit reporting fails when the absent reports directory is used.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Migrates integration tests from Jest to node:test for Probot 14 compatibility.

Changes:

  • Adds async Probot loading, request matching, logging, and teardown helpers.
  • Migrates integration suites and adds transport coverage.
  • Adds Node test scripts, JUnit reporting, and Jest exclusions.
File Description
package.json Configures Node integration tests and Jest exclusions.
test/​integration/​common.js Adds Probot 14 loading and test utilities.
test/​integration/​transport.test.js Verifies Nock interception and network blocking.
test/​integration/​triggers/​push.test.js Migrates push tests to node:test.
test/​integration/​triggers/​repository-created.test.js Migrates repository-created tests.
test/​integration/​triggers/​repository-edited.test.js Migrates repository-edited tests.
test/​integration/​plugins/​collaborators.test.js Migrates collaborator tests and body assertions.
test/​integration/​plugins/​milestones.test.js Migrates milestone tests and body assertions.
test/​integration/​plugins/​repository.test.js Migrates repository tests and updates YAML loading.
test/​integration/​plugins/​teams.test.js Migrates team tests and body assertions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread package.json
Comment thread package.json Outdated
decyjphr and others added 2 commits September 29, 2026 15:00
Updated CI integration test command to create reports directory if it doesn't exist.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Provide complete webhook payloads, exercise a deterministic repository-created trigger, and mock the admin-repository config and check-run requests used by current application behavior. Refresh plugin fixtures for current Octokit endpoints so the node:test integration command passes all tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The migrated integration suite is not invoked by the pull-request CI workflow.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)

Comment thread package.json
Run test:integration:ci on each matrix Node version and upload its JUnit report as an artifact, even when tests fail.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@decyjphr
decyjphr merged commit 3652444 into yadhav/fix-recent-issues Sep 30, 2026
2 checks passed
@decyjphr
decyjphr deleted the decyjphr-integration-tests-node-test branch September 30, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants