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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -