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 chainProxify js example chainProxify
js
chainProxify usage
// example with node-fetch and chaiconst fetch = ;const chainProxify = ;const expect = ; { to} { to} { // this two assertions will be available for every method in this class ; } { return // this {response: result} object will be second argument of the assert functions } { return // this {response: result} object will be second argument of the assert functions } { const controller = ; const expectedGetBodyPart = 'some string'; const expectedGetBodyFull = 'some string full' // can be done like TDD const response: responseTddExample = await controller; to; to; // ... usage of the response const resultTdd = responseTddExample; // can be done like BDD const response: responseBddExample = await controller // ... usage of the response const resultBdd = responseBddExample;}
proxify usage
; ; ; .isPropExists'a', 2 .isPropExists'b', 3 .isPropExists'c', 4; expecta.toEqualobj.a;expectb.toEqualobj.b;expectc.toEqualobj.c;expectproxedObj.toDeepEqualobj;