This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
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
+ ```
You can’t perform that action at this time.
0 commit comments