fix(tests): resolve macOS ARM64 mock.module failure in import test#355
Merged
Conversation
The `--yes imports a single ADR with its rules file` test failed only on macOS ARM64 (darwin-arm64) because `require()` of the same module inside a `mock.module()` factory is unreliable — it can return a circular/empty object instead of the real module exports, causing `resolveSource` and `detectTarget` to not be properly re-exported via the spread pattern. Fix: replace `require()` + spread with explicit inline implementations of `resolveSource` and `detectTarget` in the mock factory. These use the same logic as the real functions but avoid the problematic self-require. The `shallowClone` mock remains unchanged. Also compact test constants and registration tests to stay within the 500-line max-lines lint rule. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Deploying archgate-cli with
|
| Latest commit: |
9655eaa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://30ef6f4b.archgate-cli.pages.dev |
| Branch Preview URL: | https://fix-macos-import-test-mock.archgate-cli.pages.dev |
Contributor
Code Coverage
Full HTML report available in workflow artifacts. Per-directory breakdown
|
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.
Summary
require()+ spread pattern insidemock.module()factory with explicit inline implementations ofresolveSourceanddetectTargetrequire()of the same module being mocked is unreliable on macOS ARM64 (Bunmock.moduleinterop issue — returns circular/empty object instead of real exports)max-lineslint ruleContext
The
import action handler > --yes imports a single ADR with its rules filetest failed only on darwin-arm64 in run #26420753557. Linux and Windows passed fine because therequire()interop worked there.Test plan
bun run validatepasses (lint, typecheck, format, test, ADR check, knip, build)