mgspy

1.0.0 • Public • Published

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");
})

Readme

Keywords

Package Sidebar

Install

npm i mgspy

Weekly Downloads

184

Version

1.0.0

License

GPL-2.0

Unpacked Size

1.52 kB

Total Files

4

Last publish

Collaborators

  • gabrieldevlog