# test-utils **Repository Path**: mirrors_umijs/test-utils ## Basic Information - **Project Name**: test-utils - **Description**: Test utils for plugins of umi. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-18 - **Last Updated**: 2026-03-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @umijs/test-utils Test utils for plugins of umi. ## Install ```bash $ yarn add @umijs/test-utils -D ``` 依赖 umi 和 @testing-library/react,请确保同时依赖了他们。 ## Test tmp file ```js import { generateTmp, render } from '@umijs/test-utils'; test('normal', async () => { const cwd = join(fixtures, 'normal'); // 生成临时文件 await generateTmp({ cwd }); // 渲染 const { container } = render({ cwd }); // 断言 expect(container.innerHTML).toEqual('

foo

'); }); ``` ## Test HTML ```js import { generateHTML, getHTML } from '@umijs/test-utils'; test('normal', async () => { const cwd = join(fixtures, 'normal'); // 生成 HTML await generateHTML({ cwd }); // 渲染 const html = getHTML({ cwd }); // 断言 expect(html).toContain('

foo

'); }); ``` ## LICENSE MIT