Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added forwarding of stack traces from React.NET console mock
  • Loading branch information
Halstatt committed Jun 26, 2017
commit a54470a8393c7edbfc4ad3b9a23413c578e898c9
14 changes: 12 additions & 2 deletions src/React.Core/Resources/shims.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ MockConsole.prototype = {
for (var i = 1; i < arguments.length; i++) {
serializedArgs.push(JSON.stringify(arguments[i]));
}

var callstack = this._getCallStack();

this._calls.push({
method: methodName,
args: serializedArgs
args: serializedArgs,
stack: callstack ? '"Call stack: ' + callstack : 'not available'
});
},
_formatCall: function(call) {
return 'console.' + call.method + '("[.NET]", ' + call.args.join(', ') + ');';
return 'console.' + call.method + '("[.NET]", ' + call.args.join(', ') + ',' + call.stack + ');';
},
_getCallStack: function() {
var stack = new Error().stack;
return stack
? stack.replace(/[\n\r]/g, '\\n') + '"'
: '';
},
getCalls: function() {
return this._calls.map(this._formatCall).join('\n');
Expand Down