mardi 5 juillet 2016

QUnit beforeEach and afterEach with async causes test to hang

I'm not sure if I'm alone in this, but I've found that QUnit 2.0.0 will hang if you include a done = assert.async() call in both beforeEach and afterEach callbacks, like below:

<html>

<head>

<title>test_qunit</title>
<link rel="stylesheet" href="css/qunit-2.0.0.css">

</head>

<body>

        <div id="qunit"></div>
        <div id="qunit-fixture"></div>
        
        <script type="text/javascript" src="javascript/qunit-2.0.0.js"></script>
        <script type="text/javascript">
                        
                QUnit.module("async tests", {
                        beforeEach: function(assert){
                                var done = assert.async();
                                done();
                        },
                        afterEach: function(assert){
                                var abcd = assert.async();
                                abcd();
                        }
                });
                
                QUnit.test("test module", function(assert){
                        assert.equal("1","1",'1 = 1');
                });     
        
        </script>

</body>

</html>

Note that calling async in either beforeEach or afterEach works fine. Only when used in both does it cause the test to hang.

Any help in figuring out how to resolve this would be greatly appreciated. I tried to dig into the QUnit code to see if I could source the problem, but I'm pretty new to this and had a hard time finding where the bug could be coming from.

Aucun commentaire:

Enregistrer un commentaire