create an index.html file
[mkws-moved-to-github.git] / test / phantom / run-jasmine.js
index 27c465b..b3702d4 100644 (file)
@@ -46,7 +46,13 @@ function wait_for_jasmine(checkFx, readyFx, failFx, timeout) {
             clearInterval(interval);
             result.time = (new Date().getTime() - start);
             result.failed ? failFx(result) : readyFx(result);
-            phantom.exit(result.failed == 0 ? 0 : 2);
+
+            // See: https://github.com/ariya/phantomjs/issues/12697
+            // phantomjs 1.9.8
+            page.close();
+            setTimeout(function () {
+                phantom.exit(result.failed == 0 ? 0 : 2);
+            }, 0);
         }
 
         // timeout
@@ -108,14 +114,14 @@ page.open(url, function (status) {
 
     var exit = wait_for_jasmine(function () {
         return page.evaluate(function () {
-            if (!window || !window.$ || !window.mkws) {
+            if (!window || !window.mkws || !window.mkws.$) {
                 console.log("No window object found");
                 return false;
             }
 
-            var $ = window.$;
+            var $ = window.mkws.$;
             var error_msg = [""];
-            var passing = $(".passingAlert").text() || window.$(".failingAlert").text();
+            var passing = $(".passingAlert").text() || $(".failingAlert").text();
 
             // extract failed tests
             var list = $('.results > #details > .specDetail.failed');
@@ -136,7 +142,7 @@ page.open(url, function (status) {
                 html: $("html").html(),
                 duration: $(".duration").text(),
                 error_msg: error_msg,
-                failed: list.length,
+                failed: (list.length > 0 || !passing),
                 passing: passing
             };
         })