howdy,
I know there is already a question posted regarding dynamically mocking out actions in a store where it is mentioned that the action could be replaced on the store instance. I was trying to do this something like this:
Howdy,
I was wondering if you could provide and example of how one would replace an action with a jest mock function by replacing the action on the instance of the store directly. I tried this and was getting errors:
TypeError: Cannot assign to read only property '...funciton name.....' of object '[object Object]'
So for example if I had a store like this:
testStore = types.model('testStore', {
name: types.string
}).actions((self) => {
function setName(aName) {
self.name = aName;
}
return {
setName
};
});
And say I had a jest test something like this:
it('testSomething', () => {
let aStore = TestStore.create({name: 'fred'});
aStore.setName = jest.fn()
:
})
this code would give me the error noted above. What would be the way to replace the method would it be in the when doing the create?
howdy,
I know there is already a question posted regarding dynamically mocking out actions in a store where it is mentioned that the action could be replaced on the store instance. I was trying to do this something like this:
Howdy,
I was wondering if you could provide and example of how one would replace an action with a jest mock function by replacing the action on the instance of the store directly. I tried this and was getting errors:
TypeError: Cannot assign to read only property '...funciton name.....' of object '[object Object]'
So for example if I had a store like this:
testStore = types.model('testStore', {
name: types.string
}).actions((self) => {
function setName(aName) {
self.name = aName;
}
return {
setName
};
});
And say I had a jest test something like this:
it('testSomething', () => {
let aStore = TestStore.create({name: 'fred'});
aStore.setName = jest.fn()
:
})
this code would give me the error noted above. What would be the way to replace the method would it be in the when doing the create?