Я учусь шутить, тестировать реакцию js вызовы действий рефлюкса из метода componentDidMount ()
jsx импортирует вызов хранилища следующим образом
import MyStore from '~/stores/myStore'
componentDidMount() {
MyStore.getData()
}
В моем myStore.test .jsx code
import React from 'react'
import renderer from 'react-test-renderer'
jest.dontMock('./myStore.jsx')
const MyStore = require('./myStore.jsx').default
describe('', () => {
it(''), () => {
const spy = jest.spyOn(MyStore.prototype, 'MyStore.getData')
render.create(<MyStore/>).getInstance()
expect(spy).toHaveBeenCalled()
}
}
Я следил за другим похожим постом
https://stackoverflow.com/questions/43245040/using-jest-to-spy-on-method-call-in-componentdidmount
Но я получаю следующую ошибку теста шутки
Cannot spy the MyStore.getData() property because it is not a function
Я не смог найти тест на действие рефлюкса, включающий звонок в магазин.
Есть ли исправление? Есть ли лучший способ проверить вызовы в componentDidMount?
Спасибо