Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 658ab8e

Browse files
committed
add readme
1 parent a58aac6 commit 658ab8e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#loopback-testing
2+
3+
**Utilities for testing LoopBack apps**
4+
5+
## overview
6+
7+
The following helpers are designed to generate [mocha] tests against
8+
[LoopBack](http://strongloop.com/loopback) apps.
9+
10+
## install
11+
12+
```sh
13+
npm install loopback-testing --save-dev
14+
```
15+
16+
## basic usage
17+
18+
Below is a simple LoopBack app.
19+
20+
```js
21+
var loopback = require('loopback');
22+
var app = loopback();
23+
var Product = app.model('product');
24+
Product.attachTo(loopback.memory());
25+
```
26+
27+
Use the `loopback-testing` module to generate `mocha` tests.
28+
29+
```js
30+
var lt = require('loopback-testing');
31+
var assert = require('assert');
32+
33+
describe('/products', function() {
34+
lt.beforeEach.withApp(app);
35+
lt.whenCalledRemotely('GET', '/products', function() {
36+
lt.itShouldBeAllowed();
37+
it('should have statusCode 200', function() {
38+
assert.equal(this.res.statusCode, 200);
39+
});
40+
41+
lt.givenModel('product');
42+
it('should respond with an array of products', function() {
43+
assert(Array.isArray(this.res.body));
44+
});
45+
});
46+
});
47+
```

0 commit comments

Comments
 (0)