Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resolve conflict between qunit hooks for junit xml and browserscope

  • Loading branch information...
commit 3a1771bc8243279cc10fdca94e7630192ec6d7b0 1 parent 8ca0eee
@eriwen eriwen authored
Showing with 45 additions and 36 deletions.
  1. +1 −36 test/TestStacktrace.html
  2. +44 −0 test/lib/qunit-browserscope.js
View
37 test/TestStacktrace.html
@@ -24,42 +24,7 @@
<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-junit-outputter.js'></script>
- <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='lib/qunit-browserscope.js'></script>
<script type='text/javascript' src='../stacktrace.js'></script>
<script type='text/javascript' src='CapturedExceptions.js'></script>
<script type='text/javascript' src='TestStacktrace.js'></script>
View
44 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);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.