Skip to content

Commit ec630a5

Browse files
HalstattDaniel15
authored andcommitted
Added forwarding of stack traces from React.NET console mock (#419)
* Added forwarding of stack traces from React.NET console mock * Use JSON encoding to simplify stack trace handling
1 parent e6ce44a commit ec630a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/React.Core/Resources/shims.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ MockConsole.prototype = {
2323
for (var i = 1; i < arguments.length; i++) {
2424
serializedArgs.push(JSON.stringify(arguments[i]));
2525
}
26+
2627
this._calls.push({
2728
method: methodName,
28-
args: serializedArgs
29+
args: serializedArgs,
30+
stack: '\nCall stack: ' + (new Error().stack || 'not available')
2931
});
3032
},
3133
_formatCall: function(call) {
32-
return 'console.' + call.method + '("[.NET]", ' + call.args.join(', ') + ');';
34+
return 'console.' + call.method + '("[.NET]", ' + call.args.join(', ') + ', ' + JSON.stringify(call.stack) + ');';
3335
},
3436
getCalls: function() {
3537
return this._calls.map(this._formatCall).join('\n');

0 commit comments

Comments
 (0)