通用工具、组件库。 查看文档
$ npm run init
$ npm i # 为项目安装依赖
$ npm run bootstrap # 为所有字包安装依赖
$ npm run build
$ npm run publish
$ npm run release
监听文件改变,单独构建对应包。
$ npm run start
调试,创建连接
$ cd packages/ajax
$ yarn link
# cd some/project
$ yarn link @ra-lib/ajax
所有包创建连接
node scripts/link-all.js
$ npm dev
$ npm run docs:build
- @umijs/test,测试脚本,内置 jest 测试框架
- @testing-library/react,React 组件测试工具
- puppeteer,Headless 浏览器工具,用于 E2E 测试。
目录规范
.
├── package.json
├── packages
│ ├── bs-components
│ │ └── src
│ │ └── YsHeader
│ │ └── __test__
│ │ └── index.test.tsx # 插件测试用例
├── tsconfig.json
├── .fatherrc.ts
└── yarn.lock
hooks 测试示例
import { renderHook, act } from '@testing-library/react-hooks';
import useTest from '../index';
const setUp = (defaultValue?: any) => renderHook(() => useTest(defaultValue));
describe('useTest', () => {
it('should be defined', () => {
expect(useTest).toBeDefined();
});
it('test on methods', async () => {
const { result } = setUp(false);
expect(result.current[0]).toBeFalsy();
act(() => {
result.current[1](true);
});
expect(result.current[0]).toBeTruthy();
});
});
组件测试示例
import * as React from 'react';
import { render } from '@testing-library/react';
import TreeSelect from '../index';
test('TreeSelect test', () => {
const wrapper = render(<TreeSelect/>);
const el = wrapper.queryByText('pro-components TreeSelect');
expect(el).toBeTruthy();
});