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

Sinon: add support for transforming callsFake #500

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

kristerkari
Copy link
Contributor

Hello!

When running the codemods on a quite large test suite, I noticed that sinon.stub(obj, 'prop').callsFake(fn) does not seem to be transformed. Docs: https://sinonjs.org/releases/latest/stubs/#properties

I changed it so, that

sinon.stub(I18n, 'extend').callsFake(fn => fn);

will be turned into

jest.spyOn(I18n, 'extend').mockClear().mockImplementation(fn => fn);

which should be the expected result.

I also added a couple of additional test cases to verify that sinon.stub() without arguments is transformed correctly (no changes in the code were needed).

ping @skovhus

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (87daaa6) 92.39% compared to head (bf3c0e1) 92.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #500      +/-   ##
==========================================
+ Coverage   92.39%   92.42%   +0.02%     
==========================================
  Files          26       26              
  Lines        1934     1940       +6     
  Branches      404      405       +1     
==========================================
+ Hits         1787     1793       +6     
  Misses        101      101              
  Partials       46       46              
Impacted Files Coverage Δ
src/transformers/sinon.ts 90.74% <100.00%> (+0.20%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Owner

@skovhus skovhus left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for taking your time fixing this.

@skovhus skovhus merged commit b5fe411 into skovhus:main Mar 22, 2023
@kristerkari kristerkari deleted the sinon-add-support-for-callsfake branch March 22, 2023 11:47
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.

2 participants