Skip to content

Commit f93c7b2

Browse files
committed
Allow arg mismatches
1 parent 03ef2cc commit f93c7b2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/internal-test-utils/consoleMock.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,18 @@ export function createLogAssertion(
418418
let argIndex = 0;
419419
// console.* could have been called with a non-string e.g. `console.error(new Error())`
420420
// eslint-disable-next-line react-internal/safe-string-coercion
421-
String(format).replace(/%s/g, () => argIndex++);
421+
String(format).replace(/%s|%c/g, () => argIndex++);
422422
if (argIndex !== args.length) {
423-
logsMismatchingFormat.push({
424-
format,
425-
args,
426-
expectedArgCount: argIndex,
427-
});
423+
if (format.includes('%c%s')) {
424+
// We intentionally use mismatching formatting when printing badging because we don't know
425+
// the best default to use for different types because the default varies by platform.
426+
} else {
427+
logsMismatchingFormat.push({
428+
format,
429+
args,
430+
expectedArgCount: argIndex,
431+
});
432+
}
428433
}
429434

430435
// Check for extra component stacks

0 commit comments

Comments
 (0)