ライブラリのテスト...いつも楽しいです。next-i18next
NextJS プロジェクト内で使用しています。useTranslation
名前空間でフックを使用しています。
テストを実行すると、次の警告が表示されます。
console.warn react-i18next:: initReactI18next を使用して i18next インスタンスを渡す必要があります
> 33 | const { t } = useTranslation(['common', 'account']);
| ^
react-i18next テスト例からセットアップを試みましたが、成功しませんでした。私もこの提案を試しました。
useTranslation
成功せずに嘲笑しようとするだけでなく。
この警告を回避するためのより簡単な解決策はありますか? テストは FWIW に合格します...
test('feature displays error', async () => {
const { findByTestId, findByRole } = render(
<I18nextProvider i18n={i18n}>
<InviteCollectEmails onSubmit={jest.fn()} />
</I18nextProvider>,
{
query: {
orgId: 666,
},
}
);
const submitBtn = await findByRole('button', {
name: 'account:organization.invite.copyLink',
});
fireEvent.click(submitBtn);
await findByTestId('loader');
const alert = await findByRole('alert');
within(alert).getByText('failed attempt');
});
最後に、名前空間の代わりに、翻訳されたプレーンテキストを結果にする方法はありますaccount:account:organization.invite.copyLink
か?