While going over John Resig's examples, I wanted to rewrite his assertion examples using Qunit. Everything went well until I got to # 55. In Johns example to pass the test "c" (on line 7) has to be equal "undefined", now according to Qunit in my example "c" has to be equal 8. I surrounded "c" test with console.logs both of which produce undefined. Here's jsbin. Can somebody explain what's going on? me not understand...
Just in case jsbin isn't accessible, here's my code:
var a = 5;
function runMe(a){
'use strict';
test('a', function(){
strictEqual(a, 6, 'Check the value of a.');
});
function innerRun(){
test('b', function(){
strictEqual(b, 7, 'Check the value of b.');
});
console.log(c);
test('c', function(){
//the problem seems to be here
strictEqual(c, 8, 'Check the value of c.');
});
console.log(c);
}
var b = 7;
innerRun();
var c = 8;
}
runMe(6);
for ( var d = 0; d < 3; d++ ) {
setTimeout(function(){
test('d', function(){
strictEqual(d, 3, 'Check the value of d.');
});
}, 100);
}
However, if I put console.log from within the "c" test it logges out 8.