forked from axemclion/grunt-saucelabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring, the task promise is rejected when any error occurs. Its …
…main advantage is that the control flow has become much simpler, errors from multiple sources can be handled at a single point (the grunt task's entry point). Errors caused by too big test results are correctly reported (axemclion#123). Added new grunt tasks for testing test failures and too big test results.
- Loading branch information
Showing
5 changed files
with
210 additions
and
53 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
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,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Tests behavior when some of the tests fail</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script> | ||
window.onload = function () { | ||
window.global_test_results = { | ||
passed: 1, | ||
failed: 1, | ||
total: 2, | ||
duration: 1000, | ||
tests: '' | ||
}; | ||
}; | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
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,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Tests behavior when test result exceeds 64KB</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script> | ||
window.onload = function () { | ||
window.global_test_results = { | ||
passed: 1, | ||
failed: 0, | ||
total: 1, | ||
duration: 1000, | ||
tests: (function () { var foo = []; for (var i = 0; i <= Math.pow(2, 13); i++) { foo.push('01234567'); } return foo.join(''); }()) | ||
}; | ||
}; | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
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,48 @@ | ||
<html> | ||
<head> | ||
<title>Tests behavior when some of the tests fail</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="../../mocha.css" /> | ||
<script src="../../mocha.js"></script> | ||
<script>mocha.setup('bdd')</script> | ||
<script> | ||
describe('Something', function () { | ||
it('should succeed', function () { | ||
}); | ||
|
||
it('should succeed but fails', function () { | ||
throw new Error('Fails.'); | ||
}); | ||
}); | ||
onload = function(){ | ||
var runner = mocha.run(); | ||
|
||
var failedTests = []; | ||
runner.on('end', function(){ | ||
window.mochaResults = runner.stats; | ||
window.mochaResults.reports = failedTests; | ||
}); | ||
|
||
runner.on('fail', logFailure); | ||
|
||
function logFailure(test, err){ | ||
|
||
var flattenTitles = function(test){ | ||
var titles = []; | ||
while (test.parent.title){ | ||
titles.push(test.parent.title); | ||
test = test.parent; | ||
} | ||
return titles.reverse(); | ||
}; | ||
|
||
failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) }); | ||
}; | ||
}; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
</body> | ||
</html> |