Silence noisy react-intl warning in tests

This commit is contained in:
Jamie Kyle 2023-08-01 09:41:28 -07:00 committed by GitHub
parent 3fa6185d39
commit 827dc66220
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,9 @@ import type { LocaleMessageType, LocaleMessagesType } from '../types/I18N';
import type { LocalizerType } from '../types/Util';
import { strictAssert } from './assert';
import { Emojify } from '../components/conversation/Emojify';
import * as log from '../logging/log';
import * as Errors from '../types/errors';
import { Environment, getEnvironment } from '../environment';
export function isLocaleMessageType(
value: unknown
@ -52,6 +55,21 @@ export function createCachedIntl(
defaultRichTextElements: {
emojify: renderEmojify,
},
onError(error) {
log.error('intl.onError', Errors.toLogFormat(error));
},
onWarn(warning) {
if (
getEnvironment() === Environment.Test &&
warning.includes(
// This warning is very noisy during tests
'"defaultRichTextElements" was specified but "message" was not pre-compiled.'
)
) {
return;
}
log.warn('intl.onWarn', warning);
},
},
intlCache
);