pretenderjs / pretender

A mock server library with a nice routing DSL
MIT License
1.26k stars 158 forks source link

Pretender doesn't simulate empty body responses #123

Open trek opened 9 years ago

trek commented 9 years ago

An empty response can happen in the real world but makes Pretender fail.

    this.get(`/api/conversations/${conversationId}/mark_read`, function(){
      return [200, {'Content-Type': 'application/json'}, null];
    });

A PR that addresses this issue will:

fraziern commented 8 years ago

Hi, I'm looking at this. However on my unaltered clone, running npm test results in one failure:

...................08 10 2016 06:23:49.405:INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket WUSHb6RnzuGNJ48zAAAB with id 53549556
...............................08 10 2016 06:23:51.595:WARN [web-server]: 404: /some/path
.................08 10 2016 06:23:51.621:WARN [web-server]: 404: /some/path
....08 10 2016 06:23:51.693:WARN [web-server]: 404: /some/otherpath
.08 10 2016 06:23:51.714:WARN [web-server]: 404: /some/otherpath

PhantomJS 1.9.8 (Mac OS X 0.0.0) pretender invoking `onprogress` download events don't keep firing once the request has ended FAILED
    No `onprogress` events are fired after the the request finalizes
    Expected: 4
    Actual: 3
        at /Users/Nick/Sites/pretender/node_modules/qunitjs/qunit/qunit.js:1485
        at /Users/Nick/Sites/pretender/node_modules/qunitjs/qunit/qunit.js:2194
        at /Users/Nick/Sites/pretender/test/calling_test.js:423

............
Chrome 53.0.2785 (Mac OS X 10.10.5): Executed 61 of 61 SUCCESS (2.767 secs / 2.751 secs)
...................08 10 2016 06:23:52.014:WARN [web-server]: 404: /some/path
08 10 2016 06:23:52.035:WARN [web-server]: 404: /some/path
.....08 10 2016 06:23:52.103:WARN [web-server]: 404: /some/otherpath
.08 10 2016 06:23:52.123:WARN [web-server]: 404: /some/otherpath
............
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 61 of 61 (1 FAILED) (2.641 secs / 2.617 secs)
TOTAL: 1 FAILED, 121 SUCCESS

Any idea what's going on here?

EDIT: This doesn't consistently fail. Sometimes yes, sometimes no.