Additional test infra changes for toErrorDev rename (#17632)
This commit is contained in:
parent
36a6e29bb3
commit
0253ee9a2e
|
@ -12,7 +12,7 @@
|
|||
module.exports = function(context) {
|
||||
return {
|
||||
Identifier(node) {
|
||||
if (node.name === 'toWarnDev') {
|
||||
if (node.name === 'toWarnDev' || node.name === 'toErrorDev') {
|
||||
let current = node;
|
||||
while (current.parent) {
|
||||
if (current.type === 'CallExpression') {
|
||||
|
@ -22,7 +22,10 @@ module.exports = function(context) {
|
|||
current.callee.property &&
|
||||
current.callee.property.name === 'toThrow'
|
||||
) {
|
||||
context.report(node, 'toWarnDev() matcher should not be nested');
|
||||
context.report(
|
||||
node,
|
||||
node.name + '() matcher should not be nested'
|
||||
);
|
||||
}
|
||||
}
|
||||
current = current.parent;
|
||||
|
|
|
@ -108,14 +108,24 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
|
|||
.join('\n')}`
|
||||
);
|
||||
|
||||
let expectedMatcher;
|
||||
switch (methodName) {
|
||||
case 'warn':
|
||||
expectedMatcher = 'toWarnDev';
|
||||
break;
|
||||
case 'error':
|
||||
expectedMatcher = 'toErrorDev';
|
||||
break;
|
||||
default:
|
||||
throw new Error('No matcher for ' + methodName);
|
||||
}
|
||||
const message =
|
||||
`Expected test not to call ${chalk.bold(
|
||||
`console.${methodName}()`
|
||||
)}.\n\n` +
|
||||
'If the warning is expected, test for it explicitly by:\n' +
|
||||
`1. Using the ${chalk.bold('.toWarnDev()')} / ${chalk.bold(
|
||||
'.toLowPriorityWarnDev()'
|
||||
)} matchers, or...\n` +
|
||||
`1. Using the ${chalk.bold('.' + expectedMatcher + '()')} ` +
|
||||
`matcher, or...\n` +
|
||||
`2. Mock it out using ${chalk.bold(
|
||||
'spyOnDev'
|
||||
)}(console, '${methodName}') or ${chalk.bold(
|
||||
|
|
Loading…
Reference in New Issue