fix: honour callThrough() set on a specific call - #2766
Open
dylanpulver wants to merge 1 commit into
Open
dylanpulver wants to merge 1 commit into
dylanpulver wants to merge 1 commit into
Conversation
behavior.isPresent() decides whether a per-call behaviour created by onCall()/onFirstCall() is used at all. It lists the flags that invoke() dispatches on, but callsThrough and callsThroughWithNew were never added to it, so a per-call .callThrough() reported "no behaviour here" and getCurrentBehavior fell back to the default behaviour. The original method was silently never called, with no error or warning. callThrough() also sets returnValueDefined to false, so nothing else in the list could compensate. This is the same regression shape as sinonjs#1526, which was fixed for exceptionCreator in 7b53434 by adding the missing flag to the same list. Co-authored-by: Claude <noreply@anthropic.com>
This branch has not been deployed
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.
Purpose (TL;DR) - mandatory
behavior.isPresent()decides whether a per-call behaviour fromonCall()/onFirstCall()is used at all. It lists the flagsinvoke()dispatches on — butcallsThroughandcallsThroughWithNewwere never added, sostub.onFirstCall().callThrough()is a silent no-op: the default behaviour runs and the original method is never called.invoke()dispatches on 14 flags;isPresent()gated 12. The two missing ones are exactly these.callThrough()also setsreturnValueDefined = false, so nothing else in the list can compensate.Same shape as #1526, which was fixed for
exceptionCreatorin 7b53434 by adding the missing flag to this same list.How to verify - mandatory
npm installnpx mocha --recursive "test/{src,issues,scripts}/**/*-test.js"Same command, same tree, three variants:
main+ the new tests onlymain+ onlycallsThroughaddedRow 1 shows the tests fail without the fix; row 2 is why both flags are needed.
npm run lint,npm run prettier:checkandnpm run test-contractare green, and the public API manifest is unchanged. I ran the Node suite locally; CI covers browser/webworker.Checklist for author
npm run lintpassesWritten with AI assistance (Claude Opus 5,
claude-opus-5).