{"action":"created","issue":{"url":"https://api.github.com/repos/angular/material/issues/2704","repository_url":"https://api.github.com/repos/angular/material","labels_url":"https://api.github.com/repos/angular/material/issues/2704/labels{/name}","comments_url":"https://api.github.com/repos/angular/material/issues/2704/comments","events_url":"https://api.github.com/repos/angular/material/issues/2704/events","html_url":"https://github.com/angular/material/issues/2704","id":73092626,"number":2704,"title":"Replacing $timeout with $interval for $mdToast for protractor","user":{"login":"adamweeks","id":190647,"avatar_url":"https://avatars.githubusercontent.com/u/190647?v=3","gravatar_id":"","url":"https://api.github.com/users/adamweeks","html_url":"https://github.com/adamweeks","followers_url":"https://api.github.com/users/adamweeks/followers","following_url":"https://api.github.com/users/adamweeks/following{/other_user}","gists_url":"https://api.github.com/users/adamweeks/gists{/gist_id}","starred_url":"https://api.github.com/users/adamweeks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamweeks/subscriptions","organizations_url":"https://api.github.com/users/adamweeks/orgs","repos_url":"https://api.github.com/users/adamweeks/repos","events_url":"https://api.github.com/users/adamweeks/events{/privacy}","received_events_url":"https://api.github.com/users/adamweeks/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/material/labels/needs:%20tests","name":"needs: tests","color":"e11d21"},{"url":"https://api.github.com/repos/angular/material/labels/P4%20-%20Reported%20By%20or%20General%20PRs/Errors%20or%20Edge%20Cases","name":"P4 - Reported By or General PRs/Errors or Edge Cases","color":"bfdadc"}],"state":"open","locked":false,"assignee":{"login":"DevVersion","id":4987015,"avatar_url":"https://avatars.githubusercontent.com/u/4987015?v=3","gravatar_id":"","url":"https://api.github.com/users/DevVersion","html_url":"https://github.com/DevVersion","followers_url":"https://api.github.com/users/DevVersion/followers","following_url":"https://api.github.com/users/DevVersion/following{/other_user}","gists_url":"https://api.github.com/users/DevVersion/gists{/gist_id}","starred_url":"https://api.github.com/users/DevVersion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevVersion/subscriptions","organizations_url":"https://api.github.com/users/DevVersion/orgs","repos_url":"https://api.github.com/users/DevVersion/repos","events_url":"https://api.github.com/users/DevVersion/events{/privacy}","received_events_url":"https://api.github.com/users/DevVersion/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/angular/material/milestones/30","html_url":"https://github.com/angular/material/milestones/1.1.0","labels_url":"https://api.github.com/repos/angular/material/milestones/30/labels","id":1459999,"number":30,"title":"1.1.0","description":"","creator":{"login":"jelbourn","id":838736,"avatar_url":"https://avatars.githubusercontent.com/u/838736?v=3","gravatar_id":"","url":"https://api.github.com/users/jelbourn","html_url":"https://github.com/jelbourn","followers_url":"https://api.github.com/users/jelbourn/followers","following_url":"https://api.github.com/users/jelbourn/following{/other_user}","gists_url":"https://api.github.com/users/jelbourn/gists{/gist_id}","starred_url":"https://api.github.com/users/jelbourn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelbourn/subscriptions","organizations_url":"https://api.github.com/users/jelbourn/orgs","repos_url":"https://api.github.com/users/jelbourn/repos","events_url":"https://api.github.com/users/jelbourn/events{/privacy}","received_events_url":"https://api.github.com/users/jelbourn/received_events","type":"User","site_admin":false},"open_issues":87,"closed_issues":69,"state":"open","created_at":"2015-12-14T19:21:59Z","updated_at":"2016-04-13T00:37:06Z","due_on":null,"closed_at":null},"comments":17,"created_at":"2015-05-04T18:30:55Z","updated_at":"2016-04-13T16:07:55Z","closed_at":null,"body":"Since the `$mdToast` service uses `$timeout` to do the hiding delay, you are unable to e2e test toasts that have a hide delay. \r\n\r\nAn example test that fails:\r\n`toast.js`\r\n```\r\n$mdToast.show(\r\n    $mdToast.simple()\r\n        .content('Saved')\r\n        .position('bottom right')\r\n);\r\n```\r\n`toast.spec.js`\r\n```\r\nvar saveAlert = element(by.css('md-toast'));\r\nbrowser.wait(function(){\r\n    return browser.isElementPresent(saveAlert);\r\n});\r\nexpect(saveAlert.getText()).toBe('Saved');\r\n``` \r\n\r\nBut, if you don't let it hide, the test will pass\r\n```\r\n$mdToast.show(\r\n    $mdToast.simple()\r\n        .content('Saved')\r\n        .position('bottom right')\r\n        .hideDelay(0)\r\n);\r\n```\r\n\r\nProtractor handles $interval's better and does not wait for the interval to finish before processing.\r\nProtractor issue reference:\r\nhttps://github.com/angular/protractor/issues/169"},"comment":{"url":"https://api.github.com/repos/angular/material/issues/comments/209525883","html_url":"https://github.com/angular/material/issues/2704#issuecomment-209525883","issue_url":"https://api.github.com/repos/angular/material/issues/2704","id":209525883,"user":{"login":"DevVersion","id":4987015,"avatar_url":"https://avatars.githubusercontent.com/u/4987015?v=3","gravatar_id":"","url":"https://api.github.com/users/DevVersion","html_url":"https://github.com/DevVersion","followers_url":"https://api.github.com/users/DevVersion/followers","following_url":"https://api.github.com/users/DevVersion/following{/other_user}","gists_url":"https://api.github.com/users/DevVersion/gists{/gist_id}","starred_url":"https://api.github.com/users/DevVersion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevVersion/subscriptions","organizations_url":"https://api.github.com/users/DevVersion/orgs","repos_url":"https://api.github.com/users/DevVersion/repos","events_url":"https://api.github.com/users/DevVersion/events{/privacy}","received_events_url":"https://api.github.com/users/DevVersion/received_events","type":"User","site_admin":false},"created_at":"2016-04-13T16:07:55Z","updated_at":"2016-04-13T16:07:55Z","body":"When we're replacing `$timeout` with `$interval`, errors will appear in the Karma tests. \r\n\r\nThis is because, `$interval` is not able to not guarantee a given delay between executions.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/4987015/14500428/60424ffa-01a2-11e6-8cc4-d21f52ade14e.png)\r\n\r\nThere are several possibilities to fix that issue:\r\n- Using async unit tests. \r\n- Keeping `$timeout` and mention the use of `ignoreSynchronization`\r\n- Using `$interval` and provide a decorator inside the Material Mocks.\r\n\r\n@ThomasBurleson "}}