1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        Enzyme用于 React 的 JS 測試工具

        聯合創(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
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

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

        手機掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            上瘾16分钟大尺度的片段 | www.av在线一线天 | 啊啊啊插插插 | 久久无码精品视频 | 久久丁香婷婷五月 | 打床炮视频网站在线 | 亚洲欧洲免费 | 亚洲男人的天堂在线观看 | 免费看成人AAAAA视频在线 | 18禁污污网站 |