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

Fix unexpected transform by sinon transformer #380

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

FLT4613
Copy link
Contributor

@FLT4613 FLT4613 commented Sep 10, 2022

This is for passing below test.

#  src/transformers/sinon.test.ts

it('Test', () => {
  expectTransformation(
    `
      import sinon from 'sinon'
      const a = '1'.toString()
    `,
    `
      const a = '1'.toString()
    `
  )
})

name in SINON_MOCK_RESETS in the original code becomes true even if the name is 'toString'. (Reference)

So the following happens:

// From
import sinon from 'sinon'
const a = '1'.toString()

// To
const a = '1'.function toString() { [native code] }()

@codecov
Copy link

codecov bot commented Sep 10, 2022

Codecov Report

Base: 92.39% // Head: 92.39% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (4bcfa30) compared to base (7e47f7a).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 4bcfa30 differs from pull request most recent head a694821. Consider uploading reports for the commit a694821 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #380      +/-   ##
==========================================
- Coverage   92.39%   92.39%   -0.01%     
==========================================
  Files          26       26              
  Lines        1934     1933       -1     
  Branches      404      404              
==========================================
- Hits         1787     1786       -1     
  Misses        101      101              
  Partials       46       46              
Impacted Files Coverage Δ
src/transformers/sinon.ts 90.51% <100.00%> (-0.04%) ⬇️

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 at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@skovhus
Copy link
Owner

skovhus commented Sep 12, 2022

Thanks. Do you mind adding a test case?

@FLT4613 FLT4613 force-pushed the fix-sinon-transformer branch from 6c5303a to 4bcfa30 Compare September 13, 2022 10:28
@FLT4613
Copy link
Contributor Author

FLT4613 commented Sep 13, 2022

Sure, I added it.

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.

Thanks!

@skovhus skovhus enabled auto-merge (squash) September 13, 2022 11:40
@skovhus skovhus merged commit f63aeef into skovhus:main Sep 13, 2022
@FLT4613 FLT4613 deleted the fix-sinon-transformer branch September 13, 2022 12:14
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