diff --git a/addon-test-support/@ember/test-helpers/-internal/build-registry.ts b/addon-test-support/@ember/test-helpers/-internal/build-registry.ts index 2df62bbbd..ccad02a6c 100644 --- a/addon-test-support/@ember/test-helpers/-internal/build-registry.ts +++ b/addon-test-support/@ember/test-helpers/-internal/build-registry.ts @@ -44,6 +44,24 @@ const ContainerProxyMixin = (Ember as any)._ContainerProxyMixin; const Owner = EmberObject.extend(RegistryProxyMixin, ContainerProxyMixin, { _emberTestHelpersMockOwner: true, + + /** + * Unregister a factory and its instance. + * + * Overrides `RegistryProxy#unregister` in order to clear any cached instances + * of the unregistered factory. + * + * @param {string} fullName Name of the factory to unregister. + * + * @see {@link https://github.com/emberjs/ember.js/pull/12680} + * @see {@link https://github.com/emberjs/ember.js/blob/v4.5.0-alpha.5/packages/%40ember/engine/instance.ts#L152-L167} + */ + unregister(fullName: string) { + this.__container__.reset(fullName); + + // We overwrote this method from RegistryProxyMixin. + this.__registry__.unregister(fullName); + }, }); /**