我正在尝试使用 next-intl 为我的 nextjs 组件创建单元测试。
我的组件:
import Head from "next/head";
import { useTranslations } from "next-intl";
export default function Home() {
const t = useTranslations("HomePage");
return (
<div>
<Head>
<title>My title goes here</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<h1>{t("welcome")}</h1>
</div>
);
}
// Get localized messages
export function getStaticProps({ locale }) {
return {
props: {
messages: require(`locales/${locale}.json`),
},
};
}
Run Code Online (Sandbox Code Playgroud)
如何在以下行中创建单元测试:
import Home from '../pages/index'
describe('Home', () => {
it('renders a …Run Code Online (Sandbox Code Playgroud)