proxify-method
Zero dependencies package. Main purpose of this package is to provide integration of the common assertions into class methods without refactoring and updates of the class methods, this package does not affect constructor, getters/setters and does not affect internal logic of the class methods. Package works with async function/Promises, and also sync common code.

Usage
ts example
js example
js
const fetch = require('node-fetch');
const {chainProxify} = require('proxify-method');
const {expect} = require('chai');
function assertResponseBody(expectedBodyTextPart, {response}) {
expect(response).to.include(expectedBodyTextPart)
}
function assertResponseBodyStrictEqual(expectedBody, {response}) {
expect(response).to.equal(bodyTextPart)
}
class ControllerIterface {
constructor() {
chainProxify('assertBodyIncludes', assertResponseBody)
.chainProxify('strictAssertBody', assertResponseBodyStrictEqual)
.initChainModel(this);
}
getDataFromServerController() {
return fetch('http://someurl.that.returns.some.data')
.then(result => result.text())
.then(result => ({response: result}))
}
postDataFromServerController() {
return fetch('http://someurl.that.should_receive.some.data', {method: 'POST', body: 'string data'})
.then(result => result.text())
.then(result => ({response: result}))
}
}
async function test() {
const controller = new ControllerIterface();
const expectedGetBodyPart = 'some string';
const expectedGetBodyFull = 'some string full'
const {response: responseTddExample} = await controller.getDataFromServerController();
expect(responseTddExample).to.include(expectedGetBodyPart);
expect(responseTddExample).to.equal(expectedGetBodyFull);
const resultTdd = responseTddExample;
const {response: responseBddExample} = await controller.getDataFromServerController()
.assertBodyIncludes(expectedGetBodyPart)
.strictAssertBody(expectedGetBodyFull)
const resultBdd = responseBddExample;
}