[devtools] qunit: show helpful data when an assertion fails
Related to #5533333.
--- a/devtools/qunit.py Wed May 20 17:25:40 2015 +0200
+++ b/devtools/qunit.py Thu May 21 16:20:04 2015 +0200
@@ -212,7 +212,15 @@
def handle_log(self):
result = self._cw.form['result']
message = self._cw.form.get('message', '<no message>')
- self._log_stack.append('%s: %s' % (result, message))
+ actual = self._cw.form.get('actual')
+ expected = self._cw.form.get('expected')
+ source = self._cw.form.get('source')
+ log = '%s: %s' % (result, message)
+ if result == 'false' and actual is not None and expected is not None:
+ log += ' (got: %s, expected: %s)' % (actual, expected)
+ if source is not None:
+ log += '\n' + source
+ self._log_stack.append(log)
class QUnitView(View):
@@ -276,6 +284,9 @@
url: BASE_URL + 'qunit_result',
data: {"event": "log",
"result": details.result,
+ "actual": details.actual,
+ "expected": details.expected,
+ "source": details.source,
"message": details.message},
async: false});
});''')