Reset application after acceptance test

Hi there, I try to use ember-simple-auth for a project. Basically, everything works fine.

Only with the tests I have an issue: ember-simple-auth extends the beforeModel hook in the application route. So far, so good.

Now I have some unit-tests checking my own logic in the beforeModel hook in the application route. If I run them separated, they pass as expected. But if a run all the tests, beginning with some acceptance-tests, the unit-test does not pass any more, as the changes made by ember-simple-auth are still in place when I call beforeModel in my unit test.

Thus, I would probably need some tear-down code after my acceptance tests. I cannot find a way to reset the application to its original state. Can somebody give me a pointer with this?

Thank you very much!

Each test should probably establish its own preconditions. If the unit test needs a certain session to exist, it should use authenticateSession from ember-simple-auth/test-support to establish that session in its own setup.

Hi @ef4, thank you for your answer. I will give this solution a try. This may solve my issue - I will follow up with my results.

But my main question is: Why are unit-tests testing other code if I run them separately as if I run them with all my other tests together: If I run my unit test alone, it runs only against my code (my beforeModel), but if I run the whole test-suite together, the unit-test runs against the code including the changes that ember-simple-auth does to the beforeModel hook.

I actually would expect that my unit-test executes always the same code, no matter what an acceptance-test did before.

Thank you very much for your time, best regards

That’s a good question. I’m not sure, but it probably has to do with the fact that unit tests won’t run any initializers. At least, traditional unit tests won’t. If you’ve updated to the newer style tests that call setupApplicationTest then everything should be uniform.