I have a simple service for displaying flash messages https://github.com/lucassus/mongo_browser/blob/master/app/assets/javascripts/app/services.js.coffee#L31 and I’m trying to test it in e2e specs https://github.com/lucassus/mongo_browser/blob/master/spec/javascripts/e2e/databases_scenario.js.coffee#L66
I use $timeout service to hide a flash message after 3 seconds.
I noticed that e2e scenario runner blocks until the timeout flushes and I’m not able to check whether the flash message has been shown.
How to test features with $timeout in e2e specs?
Is it possible to test this kind of behavior without injecting mock services into the real application?
I don’t see a way to call
inject()in the end-to-end tests, as described by @christian-smith; this method is for the standard Jasmine tests, not the e2e test runner.I’ve created a Plunker to demonstrate.
In the example, the call to
$timeout(halfHourAction, 30*1000, false);inapp.jsmeans the tests don’t start running for 30 seconds.In my Real World® example, I’m actually polling something every 30minutes, so the app never starts running at all. Even being able to flush the
$browsers queue would only add another method to it.