lundi 4 septembre 2017

How to unit test in js without altering source code for the tests' needs and to then automate handling based on results

Let's say with have the source code for a js page. Any js page not just one that would follow revealing module pattern or something like that. I want to test that.

From what I've seen from jasmine you can do that two ways - either in the browser which works perfectly fine or I can test it with node. If I test the code in the browser I can't integrate the results of the tests in the context of a larger build like a maven build.

If I try running the tests with node I have to import dependencies. Tried to add them with require but I'm either reading wrong or it does not work since I don't get variables which are not exported. And I don't want to pollute the source code with exports and rearranging its structure just to meet the needs of the tests.

How can I do all of these things simultaneously:
1) not alter source code
2) test said source code
3) automate handling based on the results of the test




Aucun commentaire:

Enregistrer un commentaire