-
Notifications
You must be signed in to change notification settings - Fork 82
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][ts] convert sinon.SinonStub -> jest.Mock, sinon.SinonSpy -> jest.SpyInstance #359
Conversation
Codecov Report
@@ Coverage Diff @@
## main #359 +/- ##
==========================================
- Coverage 92.30% 92.28% -0.03%
==========================================
Files 26 26
Lines 1924 1905 -19
Branches 404 398 -6
==========================================
- Hits 1776 1758 -18
+ Misses 102 101 -1
Partials 46 46
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
src/transformers/sinon.ts
Outdated
export default function transformer(fileInfo: FileInfo, api: API, options) { | ||
const j = api.jscodeshift | ||
const j = api.jscodeshift.withParser(options.parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been looking for this forever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lazy web: what is this actually doing? The right parser is already selected by the CLI, so I’m curious what this is doing. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lazy web: what is this actually doing?
this took a while for me to figure out as well. this PR adds the first test case in which the code fed to expectTransformation()
is not parseable by the babel
parser. and it turns out that passing { parser: 'ts' }
to tests aren't actually causing the ts
parser to be used instead of babel
. all tests were still using babel
.
The right parser is already selected by the CLI, so I’m curious what this is doing. :)
without this, typescript in the input to expectTransformation()
yields the cryptic:
● updates types › rewrites types for mocks & stubs
SyntaxError: Missing semicolon. (4:15)
at Object._raise (node_modules/@babel/parser/src/parser/error.js:147:45)
with this line the test succeeds because the correct parser is selected. I just tried moving this to src/utils/test-helpers.ts
instead of in the "prod" code but it isn't working.
I can keep trying to find a way to make this work in test-only code or we can land for now and I'll continue as a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, moved this withTransform()
call to test-only code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
Reviewers (other than @skovhus): @catc @lencioni @jayrobin