Skip to content

Commit

Permalink
Remove shared state work around.
Browse files Browse the repository at this point in the history
The code added in an earlier commit was working around the underlying
issue. Essentially, using `getContext` in `hasPendingTransition` meant
that we were always using whatever the "last" context was and since
every test does not (and **should not**) call `setContext` we were
accidentally sharing an older tests context.

This change ensures we `setContext` up before these
`setupApplicationContext` tests (which is important), but we _also_
should add more changes to the testing harness in @ember/test-helpers
overall to ensure that each test internally cleans up the context (look
out for future PR's/commits for that)...
  • Loading branch information
rwjblue committed Jan 26, 2019
1 parent a7da312 commit 7e646a2
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions tests/unit/setup-application-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ import {
setupApplicationContext,
teardownContext,
teardownApplicationContext,
setApplication,
click,
visit,
currentRouteName,
currentURL,
setResolver,
setContext,
} from '@ember/test-helpers';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';
import { setResolverRegistry } from '../helpers/resolver';
import hbs from 'htmlbars-inline-precompile';
import { assign } from '@ember/polyfills';
import App from '../../app';
import config from '../../config/environment';

const Router = EmberRouter.extend({ location: 'none' });
Router.map(function() {
Expand All @@ -36,21 +32,8 @@ module('setupApplicationContext', function(hooks) {
if (!hasEmberVersion(2, 4)) {
return;
}
let isolatedApp;
hooks.beforeEach(async function(assert) {
const AppConfig = assign({ autoboot: false }, config.APP);
// .extend() because initializers are stored in the constructor, and we
// don't want to pollute other tests using an application created from the
// same constructor.
isolatedApp = App.extend({}).create(AppConfig);
let resolver = isolatedApp.Resolver.create({
namespace: isolatedApp,
isResolverFromTestHelpers: true,
});

setResolver(resolver);
setApplication(isolatedApp);

hooks.beforeEach(async function(assert) {
setResolverRegistry({
'router:main': Router,
'template:application': hbs`
Expand Down Expand Up @@ -85,6 +68,7 @@ module('setupApplicationContext', function(hooks) {
}),
});

setContext(this);
await setupContext(this);
await setupApplicationContext(this);
});
Expand Down

0 comments on commit 7e646a2

Please sign in to comment.