Skip to content

Instantly share code, notes, and snippets.

@rondale-sc
Created July 18, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondale-sc/8eb39a99102749eb63172ba6dd9f523f to your computer and use it in GitHub Desktop.
Save rondale-sc/8eb39a99102749eb63172ba6dd9f523f to your computer and use it in GitHub Desktop.
import { module } from 'qunit';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
import { assertionInjector, assertionCleanup } from '../assertions';
export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
assertionInjector(this.application);
// BugFix: Can be removed after 2.1. If resolver is set then fallback doesn't happen properly
// for more information: https://github.com/emberjs/ember.js/commit/e3ad9e2772e066459ddb3af78be45d9a6003f5ce
var legacyRegistry = this.application.__deprecatedInstance__.registry;
if (legacyRegistry) {
legacyRegistry.resolver = function noOpResolverBugFix() {};
}
this.register = (fullName, Factory) => {
let instance = this.application.__deprecatedInstance__;
let registry = instance.register ? instance : instance.registry;
return registry.register(fullName, Factory);
}
if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
},
afterEach() {
destroyApp(this.application);
assertionCleanup(this.application);
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment