/*global window, tester, tests, runNextTest, runtime*/ /*jslint nomen: true, emptyblock: true, unparam: true*/ (function (win) { "use strict"; // signal to UnitTester that the tests should not start automatically. win.use_karma = true; /** * Returned start function is invoked by Karma runner when Karma is * ready (connected with a browser and loaded all the required files) * * @param {Object} karma Karma runner instance * @return {Function} start function */ function createStartFn(karma) { return function () { var testCount = 0; tester.resourcePrefix = "tests/"; tester.reporter = function (r) { testCount += 1; karma.info({total: testCount}); karma.result(r); }; // tell karma how many tests there are karma.info({total: testCount}); runNextTest(tests, tester, function () { // tell karma to end the run karma.complete({ coverage: window.__coverage__ }); }); }; } /** * Returned function is used for logging by Karma */ function createDumpFn(karma, serialize) { // inside you could use a custom `serialize` function // to modify or attach messages or hook into logging return function () { karma.info({ dump: [].slice.call(arguments) }); }; } win.__karma__.start = createStartFn(window.__karma__); win.dump = createDumpFn(win.__karma__, function (value) { return value; }); }(window));