Skip to content

Commit

Permalink
Resolve conflict between qunit hooks for junit xml and browserscope
Browse files Browse the repository at this point in the history
  • Loading branch information
eriwen committed Jul 22, 2012
1 parent 8ca0eee commit 3a1771b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 36 deletions.
37 changes: 1 addition & 36 deletions test/TestStacktrace.html
Expand Up @@ -24,42 +24,7 @@
<link rel='stylesheet' href='lib/qunit.css' type='text/css' /> <link rel='stylesheet' href='lib/qunit.css' type='text/css' />
<script type='text/javascript' src='lib/qunit.js'></script> <script type='text/javascript' src='lib/qunit.js'></script>
<script type='text/javascript' src='lib/qunit-junit-outputter.js'></script> <script type='text/javascript' src='lib/qunit-junit-outputter.js'></script>
<script> <script type='text/javascript' src='lib/qunit-browserscope.js'></script>
var _bTestResults = {};

// Add URL option in QUnit to toggle publishing results to BrowserScope.org
QUnit.config.urlConfig.push("publish");
QUnit.config.testTimeout = 1000; // Timeout for async tests

// Build-up the test results beacon for BrowserScope.org
QUnit.testDone = function(test) {
// make sure all assertions passed successfully
if (!test.failed && test.total === test.passed) {
_bTestResults[test.name] = 1;
} else {
_bTestResults[test.name] = 0;
}
}

// If the user agreed to publish results to BrowserScope.org, go for it!
QUnit.done = function() {
if (QUnit.config.publish) {
var testKey = 'agt1YS1wcm9maWxlcnINCxIEVGVzdBjr68MRDA';
var newScript = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];

newScript.src = 'http://www.browserscope.org/user/beacon/' + testKey + "?callback=showResults";
firstScript.parentNode.insertBefore(newScript, firstScript);
}
}

// Load the results widget from browserscope.org
function showResults() {
var script = document.createElement('script');
script.src = "http://www.browserscope.org/user/tests/table/agt1YS1wcm9maWxlcnINCxIEVGVzdBjr68MRDA?o=js";
document.body.appendChild(script);
}
</script>
<script type='text/javascript' src='../stacktrace.js'></script> <script type='text/javascript' src='../stacktrace.js'></script>
<script type='text/javascript' src='CapturedExceptions.js'></script> <script type='text/javascript' src='CapturedExceptions.js'></script>
<script type='text/javascript' src='TestStacktrace.js'></script> <script type='text/javascript' src='TestStacktrace.js'></script>
Expand Down
44 changes: 44 additions & 0 deletions test/lib/qunit-browserscope.js
@@ -0,0 +1,44 @@
var _bTestResults = {};

// Add URL option in QUnit to toggle publishing results to BrowserScope.org
QUnit.config.urlConfig.push("publish");
QUnit.config.testTimeout = 1000; // Timeout for async tests

// Prevent overwriting other hooks
if (typeof QUnit.testDone === 'function') {
QUnit.oldTestDone = QUnit.testDone;
}
if (typeof QUnit.done === 'function') {
QUnit.oldDone = QUnit.done;
}

// Build-up the test results beacon for BrowserScope.org
QUnit.testDone = function(test) {
QUnit.oldTestDone && QUnit.oldTestDone(test);
// make sure all assertions passed successfully
if (!test.failed && test.total === test.passed) {
_bTestResults[test.name] = 1;
} else {
_bTestResults[test.name] = 0;
}
}

// If the user agreed to publish results to BrowserScope.org, go for it!
QUnit.done = function(result) {
QUnit.oldDone && QUnit.oldDone(result);
if (QUnit.config.publish) {
var testKey = 'agt1YS1wcm9maWxlcnINCxIEVGVzdBjr68MRDA';
var newScript = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];

newScript.src = 'http://www.browserscope.org/user/beacon/' + testKey + "?callback=showResults";
firstScript.parentNode.insertBefore(newScript, firstScript);
}
}

// Load the results widget from browserscope.org
function showResults() {
var script = document.createElement('script');
script.src = "http://www.browserscope.org/user/tests/table/agt1YS1wcm9maWxlcnINCxIEVGVzdBjr68MRDA?o=js";
document.body.appendChild(script);
}

0 comments on commit 3a1771b

Please sign in to comment.