QUnit + PhantomJS: asyncTest never returns

I had a problem trying to configure PhantomJS, so I could perform continuous integration in my JavaScript project through Travis CI.

In principle, even the simplest asyncTestsimply does not return. It works great when testing with nodeor in a browser, such as Chrome.

My asyncTestlooks like this:

asyncTest ("async test", function() {
    expect(1);
    console.log("Beginning test...");
    setTimeout(function() {
        ok(true, "true is true");
        start();
        console.log("Test should now end...");
    }, 200);
});

I created a repository with minimal code to reproduce the problem:

https://github.com/siovene/phantomjs-async-test

I would be grateful for any help!

+5
source share
1 answer

Salvatore

Hey. I found the problem within qunit-logging.js. When I removed this from your index.html, the tests went fine.

, qunit phantomjs.\

C:\temp\qunit_test > c:\ phantom\phantomjs.exe runner.js:///c:/temp/qunit_test/index.html

Results:
Beginning test...
Test should now end...
Took 2045ms to run 1 tests. 1 passed, 0 failed.

, qunit cdn. , ( 2012 , ), . , index.html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Test Suite</title>

        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

    </head>
    <body>
        <div id="qunit"></div>
        <div id="qunit-fixture"></div>

            <!-- qunit -->
        <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css" type="text/css" media="screen" />
        <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
        <!--<script src="qunit-logging.js"></script>-->

        <script type='text/javascript'>
            module("lib-test");

            asyncTest ("async test", function() {
                expect(1);
                console.log("Beginning test...");
                setTimeout(function() {        
                    start();
                    ok(true, "true is true");
                    console.log("Test should now end...");
                }, 2000);
            });     

        </script>

    </body>
</html>
+1

All Articles