Search code examples
javascripttestingember.jsacceptance-testingember-testing

forcing navigator.online to false when running tests


I'm writing acceptance tests for an ember application and the application works offline. I wanted to know if there was a way to force navigator.online to false to test certain behaviours when running tests.

Thanks!


Solution

  • You can use mocking.

    Wrap the code navigator.online in a service or a utility class. Use that class in your application. Use a mock implementation of this service for your tests.