Skip to content
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

Closed
ionutmiftode opened this issue May 14, 2018 · 1 comment
Closed

Cannot override mobx actions #1545

ionutmiftode opened this issue May 14, 2018 · 1 comment

Comments

@ionutmiftode
Copy link

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 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

@mweststrate
Copy link
Member

mweststrate commented May 14, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants