{"action":"opened","issue":{"url":"https://api.github.com/repos/WhoopInc/supertest-as-promised/issues/14","labels_url":"https://api.github.com/repos/WhoopInc/supertest-as-promised/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/WhoopInc/supertest-as-promised/issues/14/comments","events_url":"https://api.github.com/repos/WhoopInc/supertest-as-promised/issues/14/events","html_url":"https://github.com/WhoopInc/supertest-as-promised/issues/14","id":108988417,"number":14,"title":"Creating more readable tests","user":{"login":"nareshbhatia","id":1220198,"avatar_url":"https://avatars.githubusercontent.com/u/1220198?v=3","gravatar_id":"","url":"https://api.github.com/users/nareshbhatia","html_url":"https://github.com/nareshbhatia","followers_url":"https://api.github.com/users/nareshbhatia/followers","following_url":"https://api.github.com/users/nareshbhatia/following{/other_user}","gists_url":"https://api.github.com/users/nareshbhatia/gists{/gist_id}","starred_url":"https://api.github.com/users/nareshbhatia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nareshbhatia/subscriptions","organizations_url":"https://api.github.com/users/nareshbhatia/orgs","repos_url":"https://api.github.com/users/nareshbhatia/repos","events_url":"https://api.github.com/users/nareshbhatia/events{/privacy}","received_events_url":"https://api.github.com/users/nareshbhatia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-30T00:51:40Z","updated_at":"2015-09-30T00:51:40Z","closed_at":null,"body":"[I realize that this is not a question/issue for supertest-as-promised - just trying to get an opinion from this elite group]\r\n\r\nWhen testing front-ends, there is a great pattern for hiding the low-level details for interacting with the page - it's called the [Page Object](http://martinfowler.com/bliki/PageObject.html). Is it a best practice to do the same when testing REST APIs? Are there any examples of this?\r\n\r\n**Detail**\r\nHere's a test written using the Page Object pattern. Note that the details of interacting with the page are encapsulated in the Page Object and hence the test is easily readable:\r\n\r\n    describe('Accounts page', function() {\r\n\r\n        // Given an account called \"BofA Checking\"\r\n        // When I change the account name to \"Bank of America Checking\"\r\n        // Then the accounts page should show an account called \"Bank of America Checking\"\r\n\r\n        it('should allow changing the name of an account', function *() {\r\n            var page = new AccountsPage();\r\n\r\n            yield page.createAccount('BofA Checking');\r\n\r\n            yield page.changeAccountName('BofA Checking', 'Bank of America Checking');\r\n\r\n            var exists = yield page.doesAccountExist('Bank of America Checking');\r\n            expect(exists).to.be.true;\r\n        });\r\n    });\r\n\r\nI am wondering if people have attempted similar things at the REST API level? For example:\r\n\r\n    describe('Accounts API', function() {\r\n\r\n        // Given an account called \"BofA Checking\"\r\n        // When I change the account name to \"Bank of America Checking\"\r\n        // Then the accounts page should show an account called \"Bank of America Checking\"\r\n\r\n        it('should allow changing the name of an account', function *() {\r\n            var res = new AccountsResource();\r\n\r\n            var account = yield res.createAccount('BofA Checking');\r\n\r\n            yield res.changeAccountName(account.id, 'Bank of America Checking');\r\n\r\n            var changedAccount = yield res.getAccount(account.id);\r\n            expect(changedAccount.name).to.equal('Bank of America Checking');\r\n        });\r\n    });\r\n"}}