lundi 28 mai 2018

Automatically run complete code base in IE11 and check for syntax problems

Our JavaScript web application has a rather big code base. It is required to work in Internet Explorer 11. One of our biggest problems is that far too often, programmers (both our own and 3rd party) use JavaScript functions like contains or startsWith which are not implemented in IE11. Of course, unit tests would detect problems like that. However, writing of those lag behind and the code coverage is embarrassing small.

So, I'm wondering: Is there a fast and easy way to run a complete web application/JavaScript file in IE11 without any expectations and just checking for syntax problems?

E.g. assume you have a code snippet like this:

if(myVar == 12) {
    var someString = 'foohoo';
    var doesMyStringStartWithSomething = someString.startsWith('f');
    return 24 + 3;
  }

In "normal" unit tests, you would have to mock myVar and expect some return value. What I have in mind is: Run the code, entering each line, regardless if it is in a conditional block or in a function which is never called or whatever: Simply try to execute it. If there is a syntax problem (like in this case something like: "Object foohoo has no method 'startsWith'"), then stop with an error. And don't care about the results: E.g. if the browser miscalculates 24 + 3 and returns 666 instead of 27, we wouldn't care at this point.

End-to-end tests with something like Protractor are not a solution here, because you have to write test cases here, too, in order to trigger the execution of all bits and pieces of JavaScript.

Aucun commentaire:

Enregistrer un commentaire