Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run tests on sources and then on their minified version

I have JS project: source code + tests. For now tests are run on original sources, everything works great.

But then sources are minified and I want to run all my tests on their minified version as well. Notice, all function names are renamed because of minification. Is it resolvable task? Ideally would be don't make much changes in tests / sources.

My configuration for now is: TeamCity, karma.js + mocha, closure compiler (advanced optimization).

like image 439
Serge Avatar asked Nov 13 '22 02:11

Serge


1 Answers

our approach is as follows. We use the testing suite that comes with closure, we write our tests as per normal and then we use goog.exportSymbol to get the tests working with advanced compilation via "reflection" example:

product.path.SomethingRegressionTest.prototype.placeInvalidSession = function() {
...
}
goog.exportSymbol('test_placeInvalidSession', function() {
  core.inject(product.path.SomethingRegressionTest).placeInvalidSession();
});

We use injection here, and in the teardown we destroy all injected instances, but there are a few approaches you could use.

like image 132
lennel Avatar answered Nov 15 '22 00:11

lennel