Skip to content

Fix stub instance call order in sandboxes - #2761

Open
tianrking wants to merge 1 commit into
sinonjs:mainfrom
tianrking:fix/stub-instance-call-order
Open

Fix stub instance call order in sandboxes#2761
tianrking wants to merge 1 commit into
sinonjs:mainfrom
tianrking:fix/stub-instance-call-order

Conversation

@tianrking

Copy link
Copy Markdown

Purpose (TL;DR) - mandatory

Fix #2760 so methods created by createStubInstance participate in call-order comparisons with spies and stubs from the same sandbox.

Background (Problem in detail)

Sandbox spies and stubs use a private call-ID context, but createStubInstance created its method stubs through the default global context. As a result, calledBefore and calledAfter compared unrelated counters and could report the wrong order.

Solution

Thread the sandbox call-ID context into stub-instance creation, while preserving the standalone helper's existing default behavior. The root Sinon API now delegates to its root sandbox implementation so collection and call ordering follow the same path.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npx mocha test/src/create-sinon-api-test.js test/src/sandbox-test.js --timeout 10000
  4. npm run lint

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

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.

createStubInstance() doesn't receive per-sandbox callId context, breaking calledAfter/calledBefore vs spy()

1 participant