jestjs - Jest createSpyObj -
with chai, can create spy object follows:
chai.spy.object([ 'push', 'pop' ]);
with jasmine, can use:
jasmine.createspyobj('tape', ['play', 'pause', 'stop', 'rewind']);
what's jest equivalent?
context: migrating (typescript) jasmine tests (typescript) jest. migration guide useless in case: https://facebook.github.io/jest/docs/migration-guide.html relatively new tech, there's nothing can found in docs this.
i've written quick createspyobj function jest, support old project. ported jasmine's implementation.
export const createspyobj = (basename, methodnames): { [key: string]: mock<any> } => { let obj: = {}; (let = 0; < methodnames.length; i++) { obj[methodnames[i]] = jest.fn(); } return obj; };
Comments
Post a Comment