Format messages in unexpected console.error() test failure
This commit is contained in:
parent
2c560cb995
commit
2a1bc3f74c
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const chalk = require('chalk');
|
||||
const util = require('util');
|
||||
|
||||
if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
|
||||
// Inside the class equivalence tester, we have a custom environment, let's
|
||||
|
@ -63,14 +64,14 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
|
|||
|
||||
['error', 'warn'].forEach(methodName => {
|
||||
const unexpectedConsoleCallStacks = [];
|
||||
const newMethod = function(message) {
|
||||
const newMethod = function(format, ...args) {
|
||||
// Capture the call stack now so we can warn about it later.
|
||||
// The call stack has helpful information for the test author.
|
||||
// Don't throw yet though b'c it might be accidentally caught and suppressed.
|
||||
const stack = new Error().stack;
|
||||
unexpectedConsoleCallStacks.push([
|
||||
stack.substr(stack.indexOf('\n') + 1),
|
||||
message,
|
||||
util.format(format, ...args),
|
||||
]);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue