Skip to content

Commit ed0ef73

Browse files
author
Carlos Atencio
committed
Improved documentation and examples on asserting a single request
1 parent a5cb511 commit ed0ef73

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ For testing or debugging purposes, it is possible to extract a list of http requ
173173

174174
It is also possible to clear the list of requests with the `clearRequests()` method.
175175

176+
If you wish to only assert a single request made as opposed to the full list of requests, then you can do the following:
177+
178+
mock.requestsMade().then(function(requests){
179+
expect(requests[1]).toEqual({ url : '/users', method : 'GET' })
180+
});
181+
176182
### Runtime mocks
177183
If there is a need to add or remove mocks during test execution, please use the `add()` and `remove()` functions:
178184

example/protractor-conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var config = {
22
baseUrl: 'http://localhost:8000/',
33
specs: [
4-
'spec/*.spec.js'
4+
'spec/requestsMade.spec.js'
55
],
66
mocks: {
77
dir: 'mocks',

example/spec/requestsMade.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ describe('requests made', function(){
6060
]);
6161
});
6262

63+
it('can evaluate just the last request made', function(){
64+
mock.requestsMade().then(function(requests){
65+
expect(requests[1]).toEqual({ url : '/users', method : 'GET' })
66+
});
67+
});
68+
6369
it('can clear requests', function(){
6470
mock.clearRequests();
6571
expect(mock.requestsMade()).toEqual([]);

0 commit comments

Comments
 (0)