-
-
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
Mobx 6.1 breaks spying on actions in unit test #2752
Comments
Not yet, but we would like to adress this somehow and we are open to suggestions. |
We would like to know if it's only about writability of actions or whether we should also expect demand for configurability of actions or other fields (computed/observable). |
It might be helpful:
|
Are actions still configurable? If so, then maybe before applying the spy I can make it temporarily writable? |
Depends if it's plain object or not. All annotated fields of non-plain objects (classes) are non-configurable as well. |
I'm using classes, so what can I expect? |
Non-configurable ... the main reason is that we want to prevent following: class Child extends Parent {
// This is like calling defineProperty with new descriptor
// It breaks all assumptions we made about the field in parent
// and there is no reasonable way for us to detect this.
// So we prevent it by making the field non-configurable in parent
inheritedProp = 5;
inheritedArrowFunc = () => {};
} |
@urugator I think being able to mock/spy actions is good enough. I cannot think about a use case where mocking an observable or computed is necessary (or even good practice?). I've being writing MobX specs in large code bases for over a year and never had the need to mock an observable or computed. Unfortunately version 6.1 broke many specs so upgrading is not an option for us till this is fixed. Thanks for your work!
|
@josuemontano Is there anything specific you would like to see addressed or behaving differently? |
What I meant was, what can I expect from your solution to this issue? |
Check the 6.1.2 release notes on 😊
…On Fri, 29 Jan 2021, 17:21 Heath C, ***@***.***> wrote:
I'm using classes, so what can I expect?
What I meant was, what can I expect from your solution to this issue?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2752 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBDVVMQCLJAKYP4YGT3S4LVCZANCNFSM4WWF3GEA>
.
|
This seems to break
As you can guess, I'm worried about the second case. I wonder if there are any solutions to make it at least fail instantly, other than copying React and running everything twice. EDIT: I'm mostly interested having all |
Took me a while to understand why this happens and I've learned something new about JS :D |
Can we close this or are there any remaining issues? For future readers, since 6.1.2 there is a new configuration option |
Closing issue as to many different symptoms are already being discussed. New issues can be reported in a fresh issue with a repro against 6.1.4 |
Intended outcome:
In our unit tests we are using the
jest.spyOn()
function to ensure that certain actions are called under certain conditions (with expected values) in our components.Actual outcome:
With the 6.1 release changes all of our spys are failing in the same manner as below
results in:
How to reproduce the issue:
I'm pretty sure it's obvious how to reproduce the issue. My question is HOW can I verify that an action on an observable is called with the proper arguments now that 6.1 is available? Is there an option I can set to turn off making actions read-only for tests?
Versions
6.0.4 - working
6.1 - not working
The text was updated successfully, but these errors were encountered: