{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"Angular tests","type":"basic","slug":"angular-tests","excerpt":"","body":"[ng-describe](https://github.com/kensho/ng-describe) is available out of the box, for you to write fluent tests for your angular app.\n\n**ng-describe** makes it very easy to test **components**, **services**, **inject dependencies** and **mock ajax calls**.\nYou can browse the tests available for the **login** or **register** components.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Angular Generators\",\n  \"body\": \"for **components**, **directives** and **services** automatically generate the ng-describe spec file. You would just need to implement the test cases.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ngDescribe({\\n    name: 'Test forgot-password component',\\n    modules: 'app',\\n    inject: '$http',\\n    element: '<forgot-password></forgot-password>',\\n    http: {\\n        post: {\\n            '/api/auth/password/email': {\\n                data: true\\n            }\\n        }\\n    },\\n    tests: function(deps) {\\n\\n        it('should request email verification successfully', () => {\\n            var component = deps.element.isolateScope().vm;\\n\\n            component.email = 'email:::at:::localhost.com';\\n            component.submit();\\n\\n            deps.http.flush();\\n        });\\n    }\\n});\\n\",\n      \"language\": \"javascript\",\n      \"name\": \"forgot_password.spec.js\"\n    }\n  ]\n}\n[/block]","updates":["58b14d0dcd7f282500fb0bb2"],"order":2,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"57ffd85f755a2e1700c2bb1e","parentDoc":null,"project":"567083021dabd80d00b122ae","user":"567082433a32d20d00c45cab","version":{"version":"3.4","version_clean":"3.4.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["57ffd85f755a2e1700c2bb06","57ffd85f755a2e1700c2bb07","57ffd85f755a2e1700c2bb08","57ffd85f755a2e1700c2bb09","57ffd85f755a2e1700c2bb0a","57ffd85f755a2e1700c2bb0b","57ffd85f755a2e1700c2bb0c","57ffd85f755a2e1700c2bb0d"],"_id":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae","releaseDate":"2016-10-13T18:54:23.018Z","__v":1,"createdAt":"2016-10-13T18:54:23.018Z"},"__v":1,"createdAt":"2016-04-20T21:29:41.082Z","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Testing","slug":"testing","order":6,"from_sync":false,"reference":false,"_id":"57ffd85f755a2e1700c2bb0c","project":"567083021dabd80d00b122ae","createdAt":"2015-12-18T23:14:31.389Z","version":"57ffd85f755a2e1700c2bb05","__v":0},"githubsync":""}
[ng-describe](https://github.com/kensho/ng-describe) is available out of the box, for you to write fluent tests for your angular app. **ng-describe** makes it very easy to test **components**, **services**, **inject dependencies** and **mock ajax calls**. You can browse the tests available for the **login** or **register** components. [block:callout] { "type": "info", "title": "Angular Generators", "body": "for **components**, **directives** and **services** automatically generate the ng-describe spec file. You would just need to implement the test cases." } [/block] [block:code] { "codes": [ { "code": "ngDescribe({\n name: 'Test forgot-password component',\n modules: 'app',\n inject: '$http',\n element: '<forgot-password></forgot-password>',\n http: {\n post: {\n '/api/auth/password/email': {\n data: true\n }\n }\n },\n tests: function(deps) {\n\n it('should request email verification successfully', () => {\n var component = deps.element.isolateScope().vm;\n\n component.email = '[email protected]';\n component.submit();\n\n deps.http.flush();\n });\n }\n});\n", "language": "javascript", "name": "forgot_password.spec.js" } ] } [/block]