mockeasy

v1.0.5
A useful mocking library
Tests Integration Framework Mock Stub

MockEasy

MockEasy is a simple yet powerful mocking library for NodeJS.

A good use case for this library is mocking data access objects in tests, negating the use of a database.

Example

// math.js
exports.increment = function(value) {
  return value++;
}
// test.js
const mockeasy = require('mockeasy');
const mockedMath = mockeasy.stub(require('./math'));

mockedMath.increment.once(function(value) {
  return 100;
});

console.log(mockedMath.increment());
// 100

console.log(mockedMath.increment());
// throws error
npm i mockeasy

Metadata

  • MIT
  • Whatever
  • Elad & Yotam Laufer
  • released 3/3/2017

Downloads