目录

@umijs/test-utils

Test utils for plugins of umi.

Install

$ yarn add @umijs/test-utils -D

依赖 umi 和 @testing-library/react,请确保同时依赖了他们。

Test tmp file

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('<h1>foo</h1>');
});

Test HTML

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('<h1>foo</h1>');
});

LICENSE

MIT

关于
30.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号