The app code:
Global = {
setCompValue : function( comp, value ){
if( comp === undefined ){
console.trace();
console.error( value );
throw new Error( 'comp is undefined' );
}
...
The QUnit test:
QUnit.test( 'Global.setCompValue called with undefined comp should throw error',
function( assert ){
assert.throws( Global.setCompValue( undefined, 0 ) );
});
I can see the trace and error printout in the console. But the test fails:
Died on test #1 @http://localhost/formsFor_testing/tests/global_tests.js:17:7
Edit
It was suggested that this question might help. But in fact following that answer I seem to find a false positive: the test passes even when the line throwing the error is commented out.
But I did find this answer useful... leading me to do this:
assert.throws( function(){ Global.setCompValue( undefined, 0 ) }, new Error( 'comp is undefined' ) );
... which appears not to produce false positives.
Aucun commentaire:
Enregistrer un commentaire