Skip to content

Commit

Permalink
Tests: Add module-nested.js test case
Browse files Browse the repository at this point in the history
This asserts the undesirable status quo, where the stack is left
in a bad state if the module closure encounters a global error while
test suites are still being loaded.

Ref qunitjs#1478.
  • Loading branch information
Krinkle committed Aug 2, 2021
1 parent 163c9bc commit 0132edd
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/cli/fixtures/expected/tap-outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ ok 3 module B > test D
# pass 2
# skip 1
# todo 1
# fail 0`,

"qunit module-nested.js":
`TAP version 13
ok 1 module 1 > test in module 1
ok 2 module 2 > module 3 > test in module 3
1..2
# pass 2
# skip 0
# todo 0
# fail 0`,

"qunit incorrect-hooks-warning/test.js":
Expand Down
37 changes: 37 additions & 0 deletions test/cli/fixtures/module-nested.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
try {
QUnit.module( "module 1", () => {
QUnit.test( "test in module 1", assert => {
assert.true( true );
} );
} );
} catch ( e ) {

// Ignore
}

try {
QUnit.module( "module 2", () => {

// trigger an error in executeNow
undefined();

QUnit.test( "test in module 2", assert => {
assert.true( true );
} );
} );
} catch ( e ) {

// Ignore
}


try {
QUnit.module( "module 3", () => {
QUnit.test( "test in module 3", assert => {
assert.true( true );
} );
} );
} catch ( e ) {

// Ignore
}
9 changes: 9 additions & 0 deletions test/cli/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,15 @@ CALLBACK: done`;
} );
} );

// Regression test for https://github.com/qunitjs/qunit/issues/1478
QUnit.test( "nested module scopes", async assert => {
const command = "qunit module-nested.js";
const execution = await execute( command );

assert.equal( execution.code, 0 );
assert.equal( execution.stdout, expectedOutput[ command ] );
} );

QUnit.test( "warns about incorrect hook usage", async assert => {
const command = "qunit incorrect-hooks-warning/test.js";
const execution = await execute( command );
Expand Down

0 comments on commit 0132edd

Please sign in to comment.