Format messages in unexpected console.error() test failure
Dan Abramov committed
Jul 19, 2018 at 12:15 UTC
2a1bc3f74c1d0f1f12359216d1c57ab6e73867dd
1 file changed
+3
-2
scripts/jest/setupTests.js
+3
-2
@@ -1,6 +1,7 @@
1
'use strict';
2
3
const chalk = require('chalk');
4
+const util = require('util');
5
6
if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
7
// Inside the class equivalence tester, we have a custom environment, let's
@@ -63,14 +64,14 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
64
65
['error', 'warn'].forEach(methodName => {
66
const unexpectedConsoleCallStacks = [];
66
- const newMethod = function(message) {
67
+ const newMethod = function(format, ...args) {
68
// Capture the call stack now so we can warn about it later.
69
// The call stack has helpful information for the test author.
70
// Don't throw yet though b'c it might be accidentally caught and suppressed.
71
const stack = new Error().stack;
72
unexpectedConsoleCallStacks.push([
73
stack.substr(stack.indexOf('\n') + 1),
73
- message,
74
+ util.format(format, ...args),
75
]);
76
};
77