Enzyme用于 React 的 JS 测试工具
Enzyme 来自 airbnb 公司,是一个用于 React 的 JavaScript 测试工具,方便你判断、操纵和历遍 React Components 输出。
Enzyme 的 API 通过模仿 jQuery 的 API ,使得 DOM 操作和历遍很灵活、直观。Enzyme 兼容所有的主要测试运行器和判断库,文档和例子使用 mocha 和 chai。
使用示例:
import { shallow } from 'enzyme';describe('<MyComponent />', () => { it('should render three <Foo /> components', () => { const wrapper = shallow(<MyComponent />); expect(wrapper.find(Foo)).to.have.length(3); }); it('should render an `.icon-star`', () => { const wrapper = shallow(<MyComponent />); expect(wrapper.find('.icon-star')).to.have.length(1); }); it('should render children when passed in', () => { const wrapper = shallow( <MyComponent> <div className="unique" /> </MyComponent> ); expect(wrapper.contains(<div className="unique" />)).to.be.true; }); it('simulates click events', () => { const onButtonClick = sinon.spy(); const wrapper = shallow( <Foo onButtonClick={onButtonClick} /> ); wrapper.find('button').simulate('click'); expect(onButtonClick.calledOnce).to.be.true; });});
评论
react-three-fiber用于 Three.js 的 React 渲染器
react-three-fiber是针对Web和react-native上的threejs的React渲染器。特点使用可重用的组件以声明方式构建动态场景图,使Threejs的处理变得更加轻松,并使代码
react-three-fiber用于 Three.js 的 React 渲染器
0