mockeasy

1.0.5 • Public • Published

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

Package Sidebar

Install

npm i mockeasy

Weekly Downloads

212

Version

1.0.5

License

MIT

Last publish

Collaborators

  • laufer
  • yotamlaufer