1.0.0 • Published 5 years ago

mgspy v1.0.0

Weekly downloads
2
License
GPL-2.0
Repository
github
Last release
5 years ago

MgSpy

Simple spy function for unit testing

Install

npm install mgspy

Usage

const makeSpy = require('mgspy');

// Tested function
function tested(callMe) {
  callMe("test");
}

it("Should call 'callMe' with one argument", () => {
  const mockCallMe = makeSpy();
  tested(mockCallMe);

  expect(mockCallMe.called).to.equal(true);
  expect(mockCallMe.lastArguments.length).to.equal(1);
  expect(mockCallMe.lastArguments[0]).to.equal("test");
})