@lugia/react-test-utils

1.0.2 • Public • Published

说明

这是一个用于快速创建测试组件的工具包

delay

    delay (time: number, callback?: Function): Promise<any>;

延迟工具方法,将setTimeout操作封装成一个Promise,方便测试使用。callback为定时器到达后要调用的方法。而Promise的结果为,callback返回的结果

createTestComponent

 createTestComponent
    (Target: React.ComponentType<any>,
     callback: (Object) => void, live?: LiveMethod): React.ComponentType<any>;

根据指定的React.Component创建一个新的组件,然后勾住响应的声明周期。

  • callback是在组件mount以后,将目标组件的ref绑定回调给方法
  • live是用来勾住各类声明周期,目前支持以下声明周期
 declare type LiveMethod = {
    componentWillReceiveProps?: Function,
    componentDidUpdate?: Function,
    shouldComponentUpdate?: Function,
  }

Readme

Keywords

none

Package Sidebar

Install

npm i @lugia/react-test-utils

Weekly Downloads

1

Version

1.0.2

License

none

Unpacked Size

9.06 kB

Total Files

4

Last publish

Collaborators

  • wangcuixia
  • szfeng
  • grguang
  • sleepyaries
  • yssinstitute
  • zenjava