Skip to content

fix: should return the same spy instance when respy#955

Merged
fi3ework merged 2 commits intomainfrom
fix/respy
Feb 9, 2026
Merged

fix: should return the same spy instance when respy#955
fi3ework merged 2 commits intomainfrom
fix/respy

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Feb 9, 2026

Summary

If you call rstest.spyOn multiple times for the same method, Rstest reuses the existing spy instead of redefining it.

const hi = {
  sayHi: () => 'hi',
};
rstest.spyOn(hi, 'sayHi').mockImplementation(() => 'hello');

expect(hi.sayHi()).toBe('hello');
// should get the same spy instance
expect(rstest.spyOn(hi, 'sayHi')).toBeCalled();

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ff892c
Status: ✅  Deploy successful!
Preview URL: https://c3b5dca5.rstest.pages.dev
Branch Preview URL: https://fix-respy.rstest.pages.dev

View logs

@9aoy 9aoy requested a review from fi3ework February 9, 2026 11:15
@fi3ework fi3ework merged commit 074162d into main Feb 9, 2026
9 checks passed
@fi3ework fi3ework deleted the fix/respy branch February 9, 2026 12:37
@9aoy 9aoy mentioned this pull request Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants