codemod icon indicating copy to clipboard operation
codemod copied to clipboard

Avoid failure when API breaks

Open berdal84 opened this issue 4 years ago • 3 comments

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,

berdal84 avatar May 06 '21 12:05 berdal84

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.

christian-bromann avatar Aug 31 '21 08:08 christian-bromann

Not sure why you closed the issue. I think this is still a cool feature request.

christian-bromann avatar Mar 07 '22 10:03 christian-bromann

It was a mistake, sorry for that.

berdal84 avatar Mar 07 '22 13:03 berdal84