enzyme

    0熱度

    2回答

    我有一個名爲「HomeContainer」的容器,向我們展示了菜單和用戶列表。 import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redu

    3熱度

    2回答

    在您對React組件的基本渲染測試中,哪種方法更穩定? const wrapper = shallow(<MyComponent />); expect(wrapper.exists()).to.equal(true); expect(wrapper.find('div').length).to.equal(1); 測試渲染子組件同樣的事情: const wrapper = shallo

    0熱度

    1回答

    我有以下時作出反應與debounceTime錯誤成分反應成分 探索在此輸入代碼 class IncrementalSearch extends React.Component { constructor(props) { super(props); this.onSearch$ = new Subject(); this.onChange = thi

    1熱度

    1回答

    我試圖在使用Enzyme for React的單元測試中模擬onClick方法。我發現很多導遊模擬一個onClick,需要一些事件e,如: handleClick(e) { // Does something } .... <MyComponent onClick = {handleClick} ></MyComponent> 但是我希望能夠模仿我的onClick不把事件

    6熱度

    1回答

    我使用的是Enzyme,我們實際上可以使用文檔中給出的example組件作爲我的問題的基礎。 我們假設這個<Foo />組件使用了ReactRouter中的<Link>組件,因此我們需要將它包裝在<MemoryRouter>中進行測試。 這裏存在問題。 it('puts the lotion in the basket',() => { const wrapper = mount(

    1熱度

    1回答

    我的組件: // @flow import React from 'react' type Props = { close: Function, name: string } const MyComponent = ({ close, name }: Props) => ( <div className='click' onClick={close}>

    1熱度

    1回答

    在集成測試中,我想測試一個連接的動作創建者被調用。 describe('SomeContainer',() => { let subject, store, fancyActionCreator beforeEach(() => { store = createStore(combineReducers({ /* ... */ })) fancyActio

    0熱度

    1回答

    所以我試圖測試一個React Native組件方法是否調用另一個方法。 const render = shallow(<Login navigator={mock Navigator} />); const instance = render.instance(); instance.fetchAuthToken = jest.fn(); render.update(); // Call

    2熱度

    2回答

    我有一個條件,如果看起來像這樣: if (history.state !== null && history.state.query) 的問題是,雖然這不開玩笑地工作,因爲history在我的測試中一個空對象。 在我的測試中需要做什麼來使用history對象?我正在Node.js服務器上使用React來運行它。不知道這是否重要,但我也使用React Router。 測試用例:組件的 befor

    0熱度

    1回答

    我正在使用Enzyme/Jest爲我的容器帽子上的函數編寫測試,它是通過複選框組件的onChange觸發的。我試圖模擬一個'改變',但是,'改變'不會觸發onChange函數被調用。不知道這裏發生了什麼......我嘗試將模擬更改爲「點擊」,刪除了目標對象,但仍然無法工作。 集裝箱 export class Data extends React.PureComponent { const