-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot override mobx actions #1545
Comments
Reproduced, will fix in next release
Op ma 14 mei 2018 om 11:59 schreef Mifi <[email protected]>:
… Hi,
In mobx 3.x I was able to mock actions using jest something like
myStore.myAction = jest.fn()
However after the update I receive the following error:
TypeError: Cannot assign to read only property 'myAction' of object
'#<MyStore>'
it seems that in mobx 4.x actions are writable: false while in 3.x were writable:
true.
I know that I can override them doing something like
Object.defineProperty(myStore, 'myAction', {value: jest.fn(), writable:
true});
but it will be a pain to change it in all the 100 failing tests :).
I saw that this was fixed in #1407
<#1407> but it seems that is not
working for me with process.env.NODE_ENV = 'test'. Any ideas why?
mobx: 4.2.1
node: v8.9.4
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1545>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhIlHFuQfwU4VyIVVittE3vmPwcgcks5tyVV5gaJpZM4T9fsQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
In mobx 3.x I was able to mock actions using jest something like
myStore.myAction = jest.fn()
However after the update I receive the following error:
TypeError: Cannot assign to read only property 'myAction' of object '#<MyStore>'
it seems that in mobx 4.x actions are
writable: false
while in 3.x werewritable: true
.I know that I can override them doing something like
Object.defineProperty(myStore, 'myAction', {value: jest.fn(), writable: true});
but it will be a pain to change it in all the 100 failing tests :).
I saw that this was fixed in #1407 but it seems that is not working for me with
process.env.NODE_ENV = 'test'
. Any ideas why?mobx: 4.2.1
node: v8.9.4
The text was updated successfully, but these errors were encountered: