-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase code coverage for QUnit.equiv, QUnit.diff, test.js. Closes #1590.
- Loading branch information
1 parent
db79953
commit dfdfd43
Showing
20 changed files
with
361 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
QUnit.test( "failing test", assert => { | ||
assert.expect( 2 ); | ||
assert.true( true ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
QUnit.test( "test with no assertions", () => { | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.config.requireExpects = true; | ||
|
||
QUnit.test( "passing test", assert => { | ||
assert.true( true ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
QUnit.config.module = "MODULE b"; | ||
|
||
QUnit.module( "Module A", () => { | ||
QUnit.test( "Test A", assert => { | ||
assert.true( false ); // fail if hit | ||
} ); | ||
} ); | ||
|
||
QUnit.module( "Module B", () => { | ||
QUnit.test( "Test B", assert => { | ||
assert.true( true ); | ||
} ); | ||
} ); | ||
|
||
QUnit.module( "Module C", () => { | ||
QUnit.test( "Test C", assert => { | ||
assert.true( false ); // fail if hit | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
process.on( "unhandledRejection", ( reason ) => { | ||
console.log( "Unhandled Rejection:", reason ); | ||
} ); | ||
|
||
QUnit.config.testTimeout = 10; | ||
|
||
QUnit.test( "slow", () => { | ||
return new Promise( resolve => setTimeout( resolve, 20 ) ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
QUnit.module( "contains a hard error in hook", hooks => { | ||
hooks.before( () => { | ||
throw new Error( "expected error thrown in hook" ); | ||
} ); | ||
QUnit.test( "contains a hard error", assert => { | ||
assert.true( true ); | ||
} ); | ||
} ); |
8 changes: 8 additions & 0 deletions
8
test/cli/fixtures/hard-error-in-test-with-no-async-handler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
QUnit.test( "contains a hard error after using `assert.async`", assert => { | ||
assert.async(); | ||
assert.true( true ); | ||
throw new Error( "expected error thrown in test" ); | ||
|
||
// the "done" callback from `assert.async` should be called later, | ||
// but the hard-error prevents the test from reaching that | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
QUnit.config.noglobals = true; | ||
|
||
QUnit.test( "adds global var", assert => { | ||
global.dummyGlobal = "hello"; // eslint-disable-line no-undef | ||
assert.true( true ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
QUnit.config.noglobals = true; | ||
|
||
QUnit.test( "adds global var", assert => { | ||
global[ "qunit-test-output-dummy" ] = "hello"; // eslint-disable-line no-undef | ||
assert.true( true ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
QUnit.config.noglobals = true; | ||
|
||
global.dummyGlobal = "hello"; // eslint-disable-line no-undef | ||
|
||
QUnit.test( "deletes global var", assert => { | ||
delete global.dummyGlobal; | ||
assert.true( true ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
process.on( "unhandledRejection", ( reason ) => { | ||
console.log( "Unhandled Rejection:", reason ); | ||
} ); | ||
|
||
QUnit.config.notrycatch = true; | ||
|
||
QUnit.module( "notrycatch", function( hooks ) { | ||
|
||
hooks.beforeEach( () => { | ||
return Promise.reject( "bad things happen sometimes" ); | ||
} ); | ||
|
||
QUnit.test( "passing test", assert => { | ||
assert.true( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.test( "semaphore is set to NaN", assert => { | ||
assert.test.semaphore = "not a number"; | ||
assert.async(); | ||
return Promise.resolve(); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
QUnit.test( "tries to 'restart' the test", assert => { | ||
assert.test.semaphore = -1; | ||
return Promise.resolve(); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.