You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-18Lines changed: 27 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,39 +19,48 @@ the testing of API routes to check that the responses match those expected creat
19
19
20
20
In order to use ``abe-express`` you will use this within your current testing setup
21
21
22
+
### Header test
23
+
24
+
This is a helper which will run a test against your API ensuring that the response matches that of your mock. In order to do this, it will match the ``status`` code of your mock, it will also test the expected ``Content-type`` matches (this is only done if your mock contains the ``Content-type`` in it's headers).
25
+
22
26
```js
23
-
var abeExpress =require('abe-express');
24
-
abeExpress.full(app, mock, example, done);
27
+
var abeExpress =require('abe-express'),
28
+
myApp =require('../app.js'),
29
+
mock =require('../mocks/example.json'),
30
+
example ='OK';
31
+
32
+
it('Should return a 200 status code', function (done) {
33
+
abeExpress.header(myApp, mock, example, done);
34
+
});
25
35
```
36
+
### Full test
26
37
27
-
```abeExpress``` also provides a header test for you to just test the response headers
38
+
This is a helper which will run all tests against your API, ensuring that the body response of your API matches that of your mock. It will also run the tests against the ``header``.
28
39
29
40
```js
30
-
abeExpress.header(app, mock, example, done);
41
+
var abeExpress =require('abe-express'),
42
+
myApp =require('../app.js'),
43
+
mock =require('../mocks/example.json'),
44
+
example ='OK';
45
+
46
+
it('Should return a 200 status code and body', function (done) {
47
+
abeExpress.full(myApp, mock, example, done);
48
+
});
31
49
```
50
+
### Params
32
51
33
-
### App
52
+
####App
34
53
35
54
This will be your Express app in which the route has been attached to in which you want to test.
36
55
37
-
### Mock
56
+
####Mock
38
57
39
58
This will be the full ``ABE-Spec`` mock in which you are wanting to test against.
40
59
41
-
### Example
60
+
####Example
42
61
43
62
This is the ``key`` within the ``examples`` object of your mock.
44
63
45
-
### Done
64
+
####Done
46
65
47
66
This is the function which your testing system will pass within a ``it`` test, to tell your test that it has completed.
48
-
49
-
Example:
50
-
51
-
```js
52
-
it('should pass', function (done) {
53
-
abeExpress(app, mock, example, done);
54
-
});
55
-
```
56
-
57
-
It is expected that you pre-load your mock file previously to be able to pass it to the helper
0 commit comments