Skip to content

Fix check_membership test failures from missing error_helpers mock#8009

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-js-tests
Dec 29, 2025
Merged

Fix check_membership test failures from missing error_helpers mock#8009
pelikhan merged 3 commits intomainfrom
copilot/fix-js-tests

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

PR #8000 added require("./error_helpers.cjs") to check_permissions_utils.cjs, breaking tests that use custom module mocking via new Function() evaluation.

Changes

  • Added afterEach import to vitest imports (was used but not imported)
  • Extended mockRequire function to handle error_helpers.cjs module
  • Propagated mockRequire to check_permissions_utils.cjs execution context
// Now handles the error helpers dependency chain
const mockRequire = modulePath => {
  if (modulePath === "./error_helpers.cjs") {
    const errorHelpersFunction = new Function("module", "exports", errorHelpersContent);
    // ... execute and return exports
  }
  if (modulePath === "./check_permissions_utils.cjs") {
    // Pass mockRequire so utils can resolve error_helpers
    const utilsFunction = new Function("core", "github", "context", "process", "module", "exports", "require", utilsContent);
    utilsFunction(mockCore, mockGithub, mockContext, process, mockModule, moduleExports, mockRequire);
  }
};

Fixes 15 failing tests in check_membership.test.cjs.

Original prompt

Reference: https://github.com/githubnext/gh-aw/actions/runs/20561124903/job/59051883350#step:6:1

Fix JS tests

Custom agent used: ci-cleaner
Tidies up the repository CI state by formatting sources, running linters, fixing issues, running tests, and recompiling workflows


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 28, 2025 23:57
…rror_helpers mock

- Added missing `afterEach` import from vitest in check_membership.test.cjs
- Updated mockRequire to handle error_helpers.cjs module required by check_permissions_utils.cjs
- Fixed 15 failing tests in check_membership.test.cjs
- All tests now pass except 3 pre-existing timeouts in safe_inputs_mcp_server.test.cjs

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix JavaScript tests for consistency and accuracy Fix check_membership test failures from missing error_helpers mock Dec 29, 2025
Copilot AI requested a review from pelikhan December 29, 2025 00:04
@pelikhan pelikhan marked this pull request as ready for review December 29, 2025 00:20
@pelikhan pelikhan merged commit 023f9ab into main Dec 29, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/fix-js-tests branch December 29, 2025 00:20
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