Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore sinon.createStubInstance() behaviour #2075

Merged

Conversation

kevinbosman
Copy link
Contributor

@kevinbosman kevinbosman commented Aug 14, 2019

Purpose (TL;DR) - mandatory

Fix issue #2073 by reusing createStubInstance() behaviour from stub.js while maintaining the sandbox collection.

Background (Problem in detail) - optional

PR #2022 redirected sinon.createStubInstance() to use the Sandbox implementation thereof. This introduced a breaking change due to the sandbox implementation not supporting property overrides.

Solution - optional

This PR extends sandbox.createStubInstance() to mimic the behaviour of the original sinon.createStubInstance() method.

Instead of duplicating the original createStubInstance() behaviour from stub.js into sandbox.js, it now calls through to the stub.js implementation, then adds all the stubs to the sandbox collection as usual.

The extra tests for property overrides in stub-test.js have also been added to sandbox-test.js to ensure the sandbox implementation now works the same as the original createStubInstance(), while maintaining backward compatibility with all existing sandbox tests.

EDIT: Added some specific tests for issue #2073 in issues-test.js.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test

Checklist for author

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

@coveralls
Copy link

coveralls commented Aug 14, 2019

Pull Request Test Coverage Report for Build 2944

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.002%) to 94.206%

Files with Coverage Reduction New Missed Lines %
sinon/sandbox.js 5 94.96%
Totals Coverage Status
Change from base Build 2939: 0.002%
Covered Lines: 1669
Relevant Lines: 1738

💛 - Coveralls

PR sinonjs#2022 redirected sinon.createStubInstance() to use the Sandbox
implementation thereof. This introduced a breaking change due to the
sandbox implementation not supporting property overrides.

Instead of duplicating the original behaviour from stub.js into
sandbox.js, call through to the stub.js implementation then add all
the stubs to the sandbox collection as usual.

Copy the missing tests from stub-test.js and add issue tests.
Copy link
Member

@mroderick mroderick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! Thank you for your contribution to Sinon!

@mroderick mroderick merged commit 157b537 into sinonjs:master Sep 2, 2019
@mroderick
Copy link
Member

This has been published as sinon@7.4.2 🚢

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.

None yet

3 participants