<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Enzyme用于 React 的 JS 測試工具

          聯(lián)合創(chuàng)作 · 2023-10-01 17:28

          Enzyme 來自 airbnb 公司,是一個用于 React 的 JavaScript 測試工具,方便你判斷、操縱和歷遍 React Components 輸出。

          Enzyme 的 API 通過模仿 jQuery 的 API ,使得 DOM 操作和歷遍很靈活、直觀。Enzyme 兼容所有的主要測試運行器和判斷庫,文檔和例子使用 mochachai

          使用示例:

          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;
            });});

           

          瀏覽 23
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  又粗又大又黄又爽无遮挡 | 国产香蕉精品视频 | 亚洲无码东京热精工厂 | 青操逼| 日本无码 视频在线观看 |