-
Notifications
You must be signed in to change notification settings - Fork 40
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
Upgrading from 5.x to 7.x produces different snapshots #50
Comments
Hi @necolas! 👋 Could you find where this change was introduced and we can determine whether to revert? |
The snapshots change in v6.0. I'm using I don't know what the cause is, it could be that my test env config needs adjusting, but I didn't find any clues in the release notes. |
Well, we moved from babel 6 to babel 7 in that version bump, so it could be just about anything. This was the commit: a174a76 We didn't really change much in there. Just what needed to be changed to support babel 7, so I'm guessing this is just a result of the babel 7 upgrade. |
Looks like your unit test fixtures are just I have no idea how babel, babel-jest, and babel-plugin-tester work together. Every time I update one of them something breaks :( |
Yeah, it's a big ball of complexity :-( Unfortunately I don't have the bandwidth to look into this. I'd say just update the snapshots and hope nothing changes in the future. This module is pretty stable at this point. Sorry I can't be any more help. |
OK, well I'm not going to do that |
Not sure why you closed this issue. Perhaps @hzoo understands why switching to |
Sorry, I was under the impression that the only concern was a few quotes and |
What i mentioned about use strict was what i saw in this repos unit tests. What I'm seeing is in the OP. Code is now being compiled down to ES5 in the snapshots |
Ok, so the problem is that it appears some babel plugins are being included in the compilation that weren't being included before. That's what it looks like to me. |
This is definitely a bug and should be fixed. I don't have the bandwidth right now, but I would like to see this looked at eventually. |
I had also ran into this issue in the past, but found it to only be If someone looking to take this on need a simple reproduction repo. Here are the updated snapshots: |
I figured out the problem. Babel is looking for your Thanks for your patience. |
Awesome, thank you! |
This did the trick, although babel is changing the single quotes to escaped double quotes: https://github.com/necolas/react-native-web/pull/1485/files. Any ideas? |
Oh, yeah, I think that we can't help babel changing it to double quotes, but there's the Actually, what would probably be better is if we use recast as our printer so the output resembles the input as closely as possible WRT formatting. I'll explore that. |
Alright, after spending some time researching this, there's apparently no way for us to get babel to not change single quotes to double quotes (even with recast). However, with recast we preserve whitespace better which is nice. I'm not certain it's worth the nuances of parser plugin issues etc. So recast is out. But I think that I will add the feature to expose a import pluginTester, {formatResultWithPrettier} from 'babel-plugin-tester'
import yourPlugin from '../your-plugin'
pluginTester({
plugin: yourPlugin,
formatResult: formatResultWithPrettier,
tests: {/* your tests */},
}) This way it would be non-breaking, un-opinionated, and easy to use. |
This fixes it! necolas/react-native-web#1485 (comment) |
I think you'll like the enhancements I have coming. It'll be a major version bump, but an easy upgrade. Should be out really soon. |
v8 has been released :) |
babel-plugin-tester
version: 7.0.1node
version: 10.16.3npm
(oryarn
) version: 1.12.1Relevant code or config
https://github.com/necolas/react-native-web/blob/master/packages/babel-plugin-react-native-web/src/__tests__/index-test.js
What you did:
Updated babel-plugin-tester from 5 to 7
What happened:
All the snapshots broke because the output is now being compiled to ES5 code
Reproduction repository:
https://github.com/necolas/react-native-web/
Problem description:
I want the snapshots not to change to compiled output
The text was updated successfully, but these errors were encountered: