codemod
codemod copied to clipboard
Avoid failure when API breaks
When trying to translate from protractor to wdio v7, I had errors about API incompatibility (ex: browser.actions) not handled by the codemod. Instead of having a blocking error (with a lot of usefull information, which a good thing) I suggest:
- To show a warning instead (with the same message and help links), to be able to finalize the auto conversion.
- To comment the problematic lines (now it should compile).
- To add a
// TODO: you have to manually do this and that, because this and that. - To add an exception just before the lines, in order to be sure a developper will handle the conversion manually and can't run this test without a failure.
Let me give you an example:
Before:
browser.actions()
.mouseMove(element)
.mouseMove({x: 200, y: 0})
.perform();
After:
throw new Error('You forgot to convert browser.actions(...), check source code at line:col ');
// TODO: convert to wdio
// <explanations here>
// browser.actions()
// .mouseMove(element)
// .mouseMove({x: 200, y: 0})
// .perform();
Regards,
Thanks @berdal84 for filing the issue. Unfortunately comments are very difficult to transform. It is not straight forward to move an expression statement into a comment. It would require some heavy refactoring. I very much like the idea though. So any contributions would be much appreciated.
Not sure why you closed the issue. I think this is still a cool feature request.
It was a mistake, sorry for that.