Skip to content

Releases: simonihmig/ember-window-mock

Release 0.7.1

15 Jul 19:59
Compare
Choose a tag to compare

🐛 Bug Fix

Committers: 1

Release 0.7.0

10 Jul 19:55
Compare
Choose a tag to compare

💥 Breaking Change

  • #191 Add compatibility for embroider (@simonihmig)
    You now have to import setupWindowMock (or reset) from 'ember-window-mock/test-support'!

🚀 Enhancement

📝 Documentation

🏠 Internal

Committers: 2

Drop node 8, Ember < 3.12

09 Feb 21:46
Compare
Choose a tag to compare

Drop node 4

03 Sep 18:01
Compare
Choose a tag to compare
  • drops support for node 4
  • updated dependencies
  • added basic TypeScript defintion

setupWindowMock

07 Jun 15:50
Compare
Choose a tag to compare
  • added setupWindowMock() to easily setup tests under the new testing APIs including resetting the state. Thanks to @makepanic

Mock even more

19 Mar 21:24
Compare
Choose a tag to compare
  • replaces localStorage in tests with a mock, same API but ephemeral storage (thanks to @alisdair)
  • adds a Proxy to all nested objects, like window.navigator. This allows to override even read-only properties, like window.navigator.userAgent
  • fixes support for relative URLs when setting window.location.href

Import all the things

13 Feb 13:50
Compare
Choose a tag to compare

This is a general overhaul of the architecture and a breaking change!

Before this change the window object (the original global or the mocked version) would be accessed as a service. But to enable this.get('window').location to work, the service was not extending form Ember.Service but instead was directly exposing the window object. This required a special initializer to register the service, with the instantiate: false flag, as Ember's DI expects a valid factory (.create()) otherwise. This had the drawback that you could not lookup the service just by Ember's naming conventions, but instead you need an initializer (for the app itself or acceptance tests), or have an explicit mockWindow() call (for integration tests). Failing to call the latter would cause any integration tests that includes a component (or any other object) that injects the service to fail with an unknown service exception. See #23.

The very first implementation of this addon was using Ember's DI to register a different service (the mock) depending on the environment (test). But the later optimization to not include the mock code into production was relying on a different technique: the mock code would go into the addon-test-support tree and thus into test-support.js, and would simply "override" the AMD module with the same name. So effectively Ember's DI was not really used to switch implementations.

This release changes the architecture to not rely on a service anymore. Instead it yields the (original or mocked in tests) window object as a direct import:

import window from 'ember-window-mock';

It also exposes a reset function to reset the state of the object across tests (e.g. window.location.href).