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

Reset test elements instead of emptying them #178

Closed
trentmwillis opened this issue Sep 16, 2016 · 5 comments
Closed

Reset test elements instead of emptying them #178

trentmwillis opened this issue Sep 16, 2016 · 5 comments

Comments

@trentmwillis
Copy link
Member

In our test suite we have a need to set some content in #ember-testing before our tests are run. This works fine for the first test, but after any test that uses moduleFor, that content is removed as part of teardownTestElements.

Instead of completely emptying the #ember-testing element, I think it would be better to cache the initial state of the element in setupTestElements and restore it in teardownTestElements.

cc @sangm

@rwjblue
Copy link
Member

rwjblue commented Sep 16, 2016

Hmm. I'm not sure of the right path forward here. #ember-testing is intended to be functionally similar to #qunit-fixture, where the actual element is completely controlled by the testing harness/framework.

I suspect using QUnit.testStart to setup your desired ember-testing element contents would be a good work around for now (maybe that is good enough? I dunno).

@rwjblue
Copy link
Member

rwjblue commented Sep 16, 2016

Welp, it looks like #qunit-fixture does get the treatment you are talking about see here.

@rwjblue
Copy link
Member

rwjblue commented Sep 16, 2016

I think this is good then, following along like the link above should work well.

@sangm
Copy link

sangm commented Sep 16, 2016

So, the issue at hand is that in testing, rootElement is set to ember-testing, and putting divs inside anything else won't let the events hash trigger...

More context:

https://github.com/emberjs/ember.js/blob/a18dc8f5c709e691560a096b5bfaae8ef624dab1/packages/ember-views/lib/system/event_dispatcher.js#L152

So if I have a div I want to test for events, it has to go inside the rootElement, which in testing is ember-testing.. You can see the problem if innerHTML = ''

@rwjblue
Copy link
Member

rwjblue commented Sep 27, 2016

Closed by #180

@rwjblue rwjblue closed this as completed Sep 27, 2016
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

3 participants