Skip to content

Commit

Permalink
Added Declarative-test-demo page
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-Ed Raffalli <[email protected]>
  • Loading branch information
marc-ed-raffalli authored and virkt25 committed May 15, 2018
1 parent befaee0 commit 7594152
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
4 changes: 4 additions & 0 deletions _data/sidebars/community_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
77 changes: 77 additions & 0 deletions pages/en/community/Declarative-test-demo.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pages/en/community/How-to-add-a-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Edit the community sidebar navigation file `_data/sidebars/community_sidebar.yml
output: 'web'
</pre>

{% 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
Expand Down

0 comments on commit 7594152

Please sign in to comment.