Last active
June 13, 2016 20:26
-
-
Save fernandes/4dd76362e6616f89cb5e4c11bfa4eff5 to your computer and use it in GitHub Desktop.
QUnit and Fixtures with timeout for a single test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QUnit.config.hidepassed = false; | |
var timeout = QUnit.config.testTimeout; | |
console.log(timeout); | |
QUnit.config.testTimeout = 10000; | |
QUnit.test( "VirtualMachines#index", function( assert ) { | |
assert.expect( 2 ); | |
var done = assert.async(2); | |
assert.equal( sum(1, 1), 2, "Passed!" ); | |
$.get( "/fixtures/virtual_machines/index_table.html", function( data ) { | |
$( "#qunit-fixture" ).html( data ); | |
length = $("table.table tbody").find('tr').length; | |
assert.equal(length, 2, "Two virtual machines listed"); | |
done(); | |
}); | |
$.get( "/fixtures/virtual_machines/index_table.html", function( data ) { | |
setTimeout(function(){ | |
console.log("Im sloowwzzzzz"); | |
done(); | |
}, 5000); | |
}); | |
QUnit.config.testTimeout = timeout; | |
console.log(QUnit.config.testTimeout); | |
}); | |
QUnit.test( "VirtualMachines#timeout", function( assert ) { | |
assert.expect( 1 ); | |
var done = assert.async(); | |
$.get( "/fixtures/virtual_machines/index_table.html", function( data ) { | |
// change timeout to 5000 to see this test fail | |
setTimeout(function(){ | |
console.log("Im sloowwzzzzz"); | |
assert.equal( sum(1, 1), 2, "Passed!" ); | |
done(); | |
}, 1000); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment