Skip to content

Commit

Permalink
Avoid issues with fallback registry caching.
Browse files Browse the repository at this point in the history
The way we are hooking into the application instance registry ultimately means
that we leak "factories". Once the first test resolves a factory for a
given name, **all other tests** will use that factory (even if
`setResolverRegistry` were called again with a different value!1!1!1!1).

This works around the immediate issue by always using the "current"
assert object instead of the closure scoped one because all of the tests
will use the same factory, and using `assert` from the first test will
cause many issues for subsequent tests.

In the long run, we need to fix this in a different way. Most likely
that means changing the way setResolverRegistry works to do something
like:

* hooking into the shared application instance
* calling unregister and reregister for each key in the pojo provided

Alternatively, we could recreate the registry instance itself (therefore
flushing any caches). I think either would work, but am not certain how
hard to implement...
  • Loading branch information
rwjblue committed Jan 26, 2019
1 parent 1b23d2a commit d115c82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/unit/setup-application-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module('setupApplicationContext', function(hooks) {
return;
}

hooks.beforeEach(async function(assert) {
hooks.beforeEach(async function() {
setResolverRegistry({
'router:main': Router,
'template:application': hbs`
Expand All @@ -57,10 +57,10 @@ module('setupApplicationContext', function(hooks) {
}),
'route:slow': Route.extend({
model() {
assert.step('model start');
QUnit.config.current.assert.step('model start');
return new Promise(resolve => {
setTimeout(() => {
assert.step('model resolving');
QUnit.config.current.assert.step('model resolving');
resolve();
}, 50);
});
Expand Down

0 comments on commit d115c82

Please sign in to comment.