eugef / node-mocks-http

Mock 'http' objects for testing Express routing functions
Other
747 stars 131 forks source link

support response.writableEnded #215

Closed taozhi8833998 closed 4 years ago

taozhi8833998 commented 4 years ago

First I'd like to thank you for such an amazing module. I am using it in my test case.

when call response.end() in my code, I will check response.writableEnded instead of response.finished, which has been deprecated since node v13.4.0, v12.16.0.

// mockResponse.js

 mockResponse.end = function(data, encoding) {
        if (_endCalled) {
            // Do not emit this event twice.
            return;
        }

        mockResponse.finished = true;
       // set writableEnded to true when end function been called
        mockResponse.writableEnded = true;
        mockResponse.headersSent = true;
       ....
}
taozhi8833998 commented 4 years ago

it has been supported in https://github.com/howardabrams/node-mocks-http/pull/203. close it.