From 75941527c48c540616c51e21825a3577556b3a40 Mon Sep 17 00:00:00 2001 From: Marc-Ed Raffalli Date: Sun, 13 May 2018 15:45:40 +0100 Subject: [PATCH] Added Declarative-test-demo page Signed-off-by: Marc-Ed Raffalli --- _data/sidebars/community_sidebar.yml | 4 ++ pages/en/community/Declarative-test-demo.md | 77 +++++++++++++++++++++ pages/en/community/How-to-add-a-project.md | 2 +- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 pages/en/community/Declarative-test-demo.md diff --git a/_data/sidebars/community_sidebar.yml b/_data/sidebars/community_sidebar.yml index fd7b0139d..b14271d56 100644 --- a/_data/sidebars/community_sidebar.yml +++ b/_data/sidebars/community_sidebar.yml @@ -29,3 +29,7 @@ children: - title: 'SuperTest models' url: SuperTest-models.html output: 'web' + + - title: 'Declarative test demo' + url: Declarative-test-demo.html + output: 'web' diff --git a/pages/en/community/Declarative-test-demo.md b/pages/en/community/Declarative-test-demo.md new file mode 100644 index 000000000..2909d7c5e --- /dev/null +++ b/pages/en/community/Declarative-test-demo.md @@ -0,0 +1,77 @@ +--- +title: Declarative test demo +keywords: automation, e2e, example, loopback, mocha, test +tags: [community_project] +sidebar: community_sidebar +permalink: /doc/en/community/Declarative-test-demo.html +summary: Example application that demonstrates using lb-declarative-e2e-test to write tests in an object definition style. +--- + +## Links + +This demo is available on Github: +[https://github.com/marc-ed-raffalli/loopback-example-tests](https://github.com/marc-ed-raffalli/loopback-example-tests) + +Library used: +[https://www.npmjs.com/package/lb-declarative-e2e-test](https://www.npmjs.com/package/lb-declarative-e2e-test) + +## Overview + +This project showcase the different features of [`lb-declarative-e2e-test`](https://www.npmjs.com/package/lb-declarative-e2e-test): +- Test hooks: `before`, `beforeEach`, `after`, `afterEach` +- Test `only` / `skip` +- Authenticated requests + - Customizable login endpoint +- Response test: + - status + - header + - body + - custom (callback) + +[`lb-declarative-e2e-test`](https://www.npmjs.com/package/lb-declarative-e2e-test) allows to write tests in an object definition style, +it combines and exposes API from [Mocha](https://mochajs.org/) and [supertest](https://github.com/visionmedia/supertest) + +Authenticated requests are fully supported, testing them becomes a no-brainer: + +```js +{ + name: 'admin CAN create', + verb: 'post', + auth: usersCredentials.admin, + body: {some: 'value'}, + url: '/some/url/', + expect: 200 +} +``` + +## Demo features + +- Tests + - [x] e2e + - [ ] model validation (wip) +- Watcher for TDD +- Coverage + +## Running the demo + +Installing dependencies: + +```bash +npm install +``` + +Run the tests with coverage analysis: + +```bash +npm test +``` + +Run the test with file watcher: + +```bash +npm run test-watch +``` + +## Requirements + +- Node >= 8 diff --git a/pages/en/community/How-to-add-a-project.md b/pages/en/community/How-to-add-a-project.md index 8ef4cfd00..a982026d3 100644 --- a/pages/en/community/How-to-add-a-project.md +++ b/pages/en/community/How-to-add-a-project.md @@ -116,7 +116,7 @@ Edit the community sidebar navigation file `_data/sidebars/community_sidebar.yml output: 'web' -{% include note.html content="Mke sure the `url` property in the sidebar matches the page's `permalink` property. +{% include note.html content="Make sure the `url` property in the sidebar matches the page's `permalink` property. " %} ## Test your change