-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Fix compatibility with Ember 3.13+ #462
Conversation
@rwjblue thoughts on this? |
@pzuraq I would be curious if you have any pointers for us to clear the state of |
I also tested this branch against our project with [email protected] and all the tests pass (without modifying the setting and getting logic).
|
I think we need failing tests otherwise PR's like #471 give the false impression that ember-mocha works with the latest stable of ember-source. |
I verified the changes here ensure my test suite passes using 3.14.x. This is not surprising as 3.14 contains minor fixes not related to tracked properties behavior. |
Same, this PR is what I needed to have my test suite working past 3.13.x (and currently works on 3.14 as well). |
Ember 3.13 introduces an inaccessible WeakMap for framework-provided setters (to support tracked properties) keyed off of the owning object. Because this is the case, merely `delete`-ing an attribute from the context won't fully clean up the context; there's still a stale setter associated with the context and property name in the WeakMap. To address this, we would either need to separate the context passed down into the @ember/test-helpers setup methods from our persistent Mocha context, or dig into Ember's private API to remove these setters from the WeakMap. While neither solution seems ideal, dealing with private API has massively less surface area to maintain, since any disposable context object would have to communicate its attributes and functions back and forth from the Mocha context to the Ember context -- a task that's perhaps not even possible to get correct for all use cases. For the method for accessing the relevant private utility function, I drew from [ember-cp-validations](https://github.com/offirgolan/ember-cp-validations/blob/41158348fe8fc67ac3f3b3838dc967f5d1b7f383/addon/-private/ember-internals.js#L3-L6).
684cb56
to
a26229a
Compare
Summary
Ember 3.13 introduces an inaccessible WeakMap for framework-provided setters (to support tracked properties) keyed off of the owning object. Because this is the case, merely
delete
-ing an attribute from the context won't fully clean up the context; there's still a stale setter associated with the context and property name in the WeakMap. To address this, we would either need to separate the context passed down into the @ember/test-helpers setup methods from our persistent Mocha context (see my previous PR #461), or dig into Ember's private API to remove these setters from the WeakMap. While neither solution seems ideal, dealing with private API has massively less surface area to maintain, since any disposable context object would have to communicate its attributes and functions back and forth from the Mocha context to the Ember context -- a task that's perhaps not even possible to get correct for all use cases.For the method for accessing the relevant private utility function, I drew from ember-cp-validations. While I don't love the idea of using private API, I'm at least comforted in knowing that other well-used addons also seem to do it. 😅
The tests are lifted directly from #461, and this PR would potentially replace it, addressing issue #430. Again, much thanks to the analysis done in the original issue and #450 & #460! 😁