{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/15","labels_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/15/comments","events_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/15/events","html_url":"https://github.com/GoogleChrome/sw-toolbox/issues/15","id":85062110,"number":15,"title":"Set up test automation","user":{"login":"wibblymat","id":393358,"avatar_url":"https://avatars.githubusercontent.com/u/393358?v=3","gravatar_id":"","url":"https://api.github.com/users/wibblymat","html_url":"https://github.com/wibblymat","followers_url":"https://api.github.com/users/wibblymat/followers","following_url":"https://api.github.com/users/wibblymat/following{/other_user}","gists_url":"https://api.github.com/users/wibblymat/gists{/gist_id}","starred_url":"https://api.github.com/users/wibblymat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wibblymat/subscriptions","organizations_url":"https://api.github.com/users/wibblymat/orgs","repos_url":"https://api.github.com/users/wibblymat/repos","events_url":"https://api.github.com/users/wibblymat/events{/privacy}","received_events_url":"https://api.github.com/users/wibblymat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-06-04T11:56:02Z","updated_at":"2016-01-08T16:09:17Z","closed_at":null,"body":"Probably involving Selenium and Travis.\r\n\r\nDepends on #5 "},"comment":{"url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/comments/170042561","html_url":"https://github.com/GoogleChrome/sw-toolbox/issues/15#issuecomment-170042561","issue_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/15","id":170042561,"user":{"login":"gauntface","id":139760,"avatar_url":"https://avatars.githubusercontent.com/u/139760?v=3","gravatar_id":"","url":"https://api.github.com/users/gauntface","html_url":"https://github.com/gauntface","followers_url":"https://api.github.com/users/gauntface/followers","following_url":"https://api.github.com/users/gauntface/following{/other_user}","gists_url":"https://api.github.com/users/gauntface/gists{/gist_id}","starred_url":"https://api.github.com/users/gauntface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gauntface/subscriptions","organizations_url":"https://api.github.com/users/gauntface/orgs","repos_url":"https://api.github.com/users/gauntface/repos","events_url":"https://api.github.com/users/gauntface/events{/privacy}","received_events_url":"https://api.github.com/users/gauntface/received_events","type":"User","site_admin":false},"created_at":"2016-01-08T16:09:16Z","updated_at":"2016-01-08T16:09:16Z","body":"@jeffposnick @wibblymat Update:\r\n\r\nI've added some tests for `.precache` and `router.get` (some based off of the origin qunit tests).\r\n\r\n`router.get` methods show how we can test requests that go through the service worker: https://github.com/GoogleChrome/sw-toolbox/blob/wider-test-coverage/test/inbrowser-tests/router-get.js\r\n\r\nThe way it works is that each test creates an `iframe`. That iframe's `src` is set to `/test/iframe/<timestamp>`. This forces it to have a unique URL between tests. The test then activates a service worker via `testHelper.activateSW`. Behind the scenes this looks for the `iframe` (given a known html class name) and if it finds one, activates the service worker with a `scope` of the iframes `src` (See: https://github.com/GoogleChrome/sw-toolbox/blob/wider-test-coverage/test/inbrowser-tests/libs/helper-functions.js#L110). After this you can use the iframe to make a request by using the iframes fetch request (this relies on the service worker the claim call in the activate step).\r\n\r\n`iframe.contentWindow.fetch(fetchUrl)`\r\n\r\nI had to create an express server to add in the `Service-Worker-Allowed` header: https://github.com/GoogleChrome/sw-toolbox/blob/wider-test-coverage/test/server/index.js#L28 and return a page for the `/test/iframe/<timestamp>` page.\r\n\r\nAt the moment creating the tests isn't too bad, but I need to play with the folder structure a little more - at the moment it feels messy. If the tests fail, debugging isn't clean. If there was a way to set up a specific test and no others without the tear down after the test would do a long way to help fixing issues, but not sure what that would look like at the moment.\r\n\r\nI've left some tests failing because I think the behaviour is worth discussing before it all goes through as passing. I may make these ignorable tests.\r\n\r\nFeedback on this would be good now that it's performing a few more tests.\r\n\r\nTo run them from gulp you can use `gulp test:manual` or `gulp:automated`. Otherwise `nodemon test/server/index.js` will also do the job."}}