Skip to content

Commit

Permalink
test: Add failure case to grunt-contrib-qunit integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Feb 6, 2022
1 parent f0c346b commit 78be2dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/cli/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ QUnit.module( "structure", () => {
assert.true( files.length > 5, "found files" );
} );

QUnit.test( "grunt-contrib-qunit", assert => {
QUnit.test( "Gruntfile", assert => {
const raw = fs.readFileSync( __dirname + "/../../Gruntfile.js", "utf8" );
const contents = raw.match( /@HTML_FILES.*?\[.*?\]/s )[ 0 ];

Expand Down
11 changes: 7 additions & 4 deletions test/integration/grunt-contrib-qunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ QUnit.test( "passing tests", assert => {
} );

QUnit.test.each( "failing tests", {
"assert": [ "fail-assert", `Testing fail-assert.html F
>> example
>> Message: some message
>> Actual: false
>> Expected: true
>> at ` ],
"no-tests": [ "fail-no-tests", `Testing fail-no-tests.html F
>> global failure
>> Message: No tests were run.
>> Error: No tests were run.
>> at done (file:)
>> at advanceTestQueue (file:)
>> at Object.advance (file:)
>> at unblockAndAdvanceQueue (file:)` ]
>> at done (file:)` ]
}, ( assert, [ command, expected ] ) => {

try {
Expand Down
1 change: 1 addition & 0 deletions test/integration/grunt-contrib-qunit/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = function( grunt ) {
}
},
pass: [ "pass-*.html" ],
"fail-assert": "fail-assert.html",
"fail-no-tests": "fail-no-tests.html"
}
} );
Expand Down
17 changes: 17 additions & 0 deletions test/integration/grunt-contrib-qunit/fail-assert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>QUnit</title>
<link rel="stylesheet" href="qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>
<script src="qunit/qunit.js"></script>
<script>
QUnit.test( "example", function( assert ) {
assert.true( false, "some message" );
} );
</script>
</body>
</html>

0 comments on commit 78be2dd

Please sign in to comment.