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

Using @ember/destroyable in teardownContext causes incompatibility with ember-mocha #986

Closed
yads opened this issue Feb 10, 2021 · 5 comments

Comments

@yads
Copy link

yads commented Feb 10, 2021

teardownContext causes ember-mocha tests to fail with:

Error: Attempted to register a destructor with an object that is already destroying or destroyed

It seems like Mocha potentially reuses contexts from test to test, so the Ember destroyable module thinks that a subsequent context is destroyed when it isn't considered destroyed by mocha or ember-mocha. This causes any tests after the first to fail at line:

associateDestroyableChild(context, owner);

This is impacting this PR in ember-mocha to uplift it to the latest version of ember-test-helpers. Only calling teardownContext on this.owner works fine in Ember 3.20, but fails in earlier versions.

@yads
Copy link
Author

yads commented Feb 10, 2021

I've figured out how to get around this by using a Proxy object as a temporary context

@yads yads closed this as completed Feb 10, 2021
@rwjblue
Copy link
Member

rwjblue commented Feb 11, 2021

Ya, the proxy solution seems good (to prevent shared mutation of the same context over and over again). Though, I think it would still be best if we add an option to disable destroying the test context.

@yads
Copy link
Author

yads commented Feb 11, 2021

@rwjblue while I have you here, can you take a look at this PR emberjs/ember-mocha#631 that I linked above? We're currently maintaining a fork of ember-mocha because it seems like the project doesn't have any maintainers. I'd love to get that merged in and perhaps take over maintenance of the project?

@rwjblue
Copy link
Member

rwjblue commented Feb 17, 2021

@yads - Can you make a new meta issue over there in ember-mocha so we can discuss the overall path forward? There are quite a few different open PRs and it isn't clear what the order of merging would be (or what is left to do, etc).

@yads
Copy link
Author

yads commented Feb 17, 2021

@rwjblue done, see emberjs/ember-mocha#638

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