You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bridge.ReservationAcceptanceAuthorization.test.ts: root-level before() hook runs for the whole mocha suite #1138
solidity/test/bridge/Bridge.ReservationAcceptanceAuthorization.test.ts declares a top-level before(async () => {...}) (line 131) outside any describe(...) block. Mocha treats this as a root hook: it runs once before the entire combined test suite, not scoped to this file, whenever the full hardhat test (no file filter) is invoked.
This is a deliberate, documented design decision, not an oversight (see the comment at lines 228-240 in the same file) - the root hook establishes the shared bridgeFixture() deployment exactly once, and the file's own establishReservationPreconditions() helper re-asserts this file's specific preconditions before each describe block, compensating for state drift from other test files that run between the root hook and this file's own tests in Mocha's combined execution order.
Risk
Because it is a root hook, a failure in it (e.g. an environment/network gap in resolving an external dependency during bridgeFixture()) aborts test collection for the entire suite, not just this file - every other test file's tests report as unrun rather than as their own independent pass/fail. This was observed locally (not in CI) when an external NuCypherToken deployment artifact could not be resolved for the in-memory hardhat network; CI itself resolves this fine, since contracts-build-and-test is green.
Suggested follow-up (not urgent, no functional bug present)
Consider whether the shared-fixture-once-per-suite goal can be achieved with a narrower mechanism (e.g. Mocha's proper mochaHooks.beforeAll root-hook-plugin convention, explicitly opted into, rather than an implicit bare before() at module scope) so a hook failure is visibly scoped to "global setup," and/or add defensive handling so a hook failure surfaces clearly as environment-only rather than looking like every file's fixture broke.
Filed as a documentation/robustness follow-up per PR #1116's review; no code change proposed here since the current behavior is intentional and CI is unaffected.
Activity
linear commentedon Sep 9, 2026
ENG-765