0
내가 모카에 구성 요소를 렌더링하기 위해 노력하고있어
에 호출되지 나는이 오류 얻을 이유를 정말 모르는 : 스파이 활동
누구나 이런 이유를 알고 있습니까? 난 수동으로 소품을 전달 해요, 효소가 실제로 connect()를 충분히 커버하지 않기 때문에 자체 컨테이너를 포장 할 때 충분합니다.
import chai from 'chai'
import React from 'react'
import { shallow, props } from 'enzyme'
import sinon from 'sinon'
import PureTestNest from '../../components/CounterNest'
import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store'
import sinonChai from 'sinon-chai'
const expect = chai.expect;
chai.use(sinonChai);
function setup(value = 0) {
const component = shallow(
<PureTestNest value={value} doIncreaseNumber={doIncreaseNumber} store={store} />
)
let doIncreaseNumber = sinon.spy()
return {
component: component,
doIncreaseNumber,
buttons: component.find('button')
}
}
const middlewares = [thunk]
let mockStore = configureStore(middlewares)
let component;
const getState = {}
const store = mockStore(getState)
describe('Components --CounterNest',() => {
it('should increment an value on a click',() => {
const { buttons, doIncreaseNumber } = setup()
buttons.at(0).simulate('click')
expect(doIncreaseNumber).to.have.been.called()
});
});
는, [REDUX 워드 프로세서 추천] (http://redux.js.org/docs/recipes/WritingTests.html#connected와
임에 익숙하지 구성 요소)는 연결된 구성 요소를 테스트하는 것이 아니라 연결된 구성 요소 (연결되기 전에)를 테스트하는 것입니다. 이렇게하려면 구성 요소를 내보낼 것을 요구합니다 (이름이 지정된 내보내기).하지만이 경우에는 문제가되지 않습니다. – kentcdodds
예, 연결하기 전에 먼저 구성 요소를 내보내므로이를 기반으로 작동해야합니다. –