Run integration suite on node:test with real Probot 14 - #1097
Merged
decyjphr merged 6 commits intoSep 30, 2026
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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
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.
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>
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>
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.


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 movestest/integrationtonode:testwhile 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
loadInstance()dynamically importsprobot, awaitsprobot.load(), and waits for the app's startupGET /app/installationscall (from the un-awaitedinfo()) so it cannot race with per-test scopes.createProbotgetsenv: {}so a developer'sAPP_ID/PRIVATE_KEY/GHE_HOSTcan't change credentials or base URL.nock.disableNetConnect()are unchanged. Teardown asserts every expected request happened, listing pending mocks and any request-body mismatches, and always runsnock.cleanAll()/mock.restoreAll()for isolation.error/fatallog orconsole.errorfails the test, including errors the app catches and logs.LOG_LEVELechoes logs to stderr for debugging.expect(body).toMatchObject(...)inside Nock matchers is replaced by abodyMatching()helper with equivalent semantics.transport.test.jsverifies Nock intercepts the Probot Octokit fetch transport the app uses, and that unmocked requests are blocked.test:integration:ci(createsreports/, emits spec output plus JUnit toreports/integration-junit.xml) now runs innode-ci.ymlon Node 22 and 24, and the JUnit report is uploaded as an artifact even on failure. Jest now ignorestest/integration.yaml.safeLoad, removed in js-yaml v4; it now usesyaml.load(own commit).Fixture updates
Once loading worked, fixtures no longer matched current app behavior. They now:
login,organization,sender,installation); plugin tests use a deterministicrepository.createdtrigger instead of a random one.<org>/admin/.github/settings.yml) and mock the suborg lookup, repo-config directory, admin commit, and check-run requests the app now makes.GETbeforePATCHon the repo).repository.editedcase 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 ontest/integrationalso pass. Node 24 is first exercised by this PR's CI run.lib/proxyAwareProbotOctokit.js(used byhandler.js) cannot berequired with the installed ESM-only Octokit plugins, so it is not covered by the transport test. That is a separate, pre-existing issue.