Skip to content

Commit

Permalink
improve failure output for added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raycohen committed Apr 10, 2021
1 parent 021956c commit 9549683
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/main/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,14 @@ QUnit.module( "QUnit.module", function() {
QUnit.module( "Improperly invoked hooks", function( hooks ) {
QUnit.module( "Nested module with different hooks variable name", function( innerHooks ) {
this.outerHookRan = false;
this.beforeEachErrorMessage = "";

try {
hooks.beforeEach( function() {
this.outerHookRan = true;
} );
} catch ( e ) {
this.beforeEachError = e;
this.beforeEachErrorMessage = e.message;
}

this.innerHookRan = false;
Expand All @@ -437,17 +439,19 @@ QUnit.module( "QUnit.module", function() {
} );

QUnit.test( "calling parent module's beforeEach errors", function( assert ) {
assert.strictEqual( this.beforeEachError.message,
"Do not invoke hooks outside of their providing module." );
assert.false( this.outerHookRan );
assert.true( this.innerHookRan );
assert.strictEqual( this.beforeEachErrorMessage,
"Do not invoke hooks outside of their providing module.",
"Correct error thrown by beforeEach" );
assert.false( this.outerHookRan, "outer hook beforeEach should not run" );
assert.true( this.innerHookRan, "inner hook beforeEach should run" );
} );
} );

QUnit.test( "hooks error when invoked during test execution", function( assert ) {
assert.throws( function() {
hooks.beforeEach( function() { } );
}, "Do not invoke hooks outside of their providing module." );
}, new RegExp( "Do not invoke hooks outside of their providing module." ),
"Correct error thrown by beforeEach" );
} );
} );
} );

0 comments on commit 9549683

Please sign in to comment.