JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.9.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.9.0.js"></script>
<div id="qunit"></div>
<div id="qunit-fixture">
</div>
JavaScript
var urls = ['http://jquery.com/favicon.ico','http://vesq.net/favicon.ico', 'http://example.com/thisDoesNotExist.jpg'];
for (var i = 0; i < urls.length; i++) {
test('image', function() {
var url = urls[i];
stop();
imageAsyncTest(url);
});
}
function imageAsyncTest(url) {
// Create a new dynamic image
var img = new Image();
// Turn it into a jQuery object
var $img = $(img);
// Hook the tests
$img.error(function() {
ok(false,'Issue loading image '+url);
start();
});
$img.load(function() {
ok(true,'Image properly loaded '+url);
start();
});
// Load the image
$img.attr('src', url);
}