qunit-logging.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // Dummy logging calls (ie, if tests are run in IE)
  2. window.console = window.console || {};
  3. window.console.log = window.console.log || function(){};
  4. window.console.debug = window.console.debug || function(){};
  5. window.console.info = window.console.info || function(){};
  6. window.console.warn = window.console.warn || function(){};
  7. window.console.error = window.console.error || function(){};
  8. (function() {
  9. var modName, testName;
  10. //arg: { name }
  11. QUnit.testStart = function(t) {
  12. modName = t.module;
  13. testName = t.name;
  14. };
  15. //arg: { name, failed, passed, total }
  16. QUnit.testDone = function(t) {
  17. if (t.failed)
  18. console.log('Test "' + t.module + ': ' + t.name + '" completed: ' + (0 === t.failed ? 'pass' : 'FAIL') + '\n')
  19. };
  20. //{ result, actual, expected, message }
  21. QUnit.log = function(t) {
  22. if (!t.result)
  23. console.log('Test "' + modName + ': ' + testName + '" assertion failed. Expected <' + t.expected + '> Actual <' + t.actual + '>' + (t.message ? ': \'' + t.message + '\'' : ''));
  24. };
  25. }());