Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
A node.js module that helps with mocking and behavior verification.
Via npm:
npm install gently@latest
Make sure your dog is working properly:
function Dog() {}
Dog.prototype.seeCat = function() {
this.bark('whuf, whuf');
this.run();
}
Dog.prototype.bark = function(bark) {
require('sys').puts(bark);
}
var gently = new (require('gently').Gently)
, assert = require('assert')
, dog = new Dog();
gently.expect(dog, 'bark', function(bark) {
assert.equal(bark, 'whuf, whuf');
});
gently.expect(dog, 'run');
dog.seeCat();
You can also easily test event emitters with this, for example a simple sequence of 2 events emitted by fs.WriteStream
:
var gently = new (require('gently').Gently)
, stream = new (require('fs').WriteStream)('my_file.txt');
gently.expect(stream, 'emit', function(event) {
assert.equal(event, 'open');
});
gently.expect(stream, 'emit', function(event) {
assert.equal(event, 'drain');
});
For a full read world example, check out this test case: test-incoming-form.js (in node-formdiable).
Creates a new gently instance. It listens to the process 'exit'
event to make sure all expectations have been verified.
Creates an expectation for an objects method to be called. You can optionally specify the call count
you are expecting, as well as mock
function that will run instead of the original function.
Returns a reference to the function that is getting overwritten.
Returns a function that is supposed to be executed count
times, delegating any calls to the provided mock
function. Naming your mock closure will help to properly diagnose errors that are being thrown:
childProcess.exec('ls', gently.expect(function lsCallback(code) {
assert.equal(0, code);
}));
Restores an object method that has been previously overwritten using gently.expect()
.
Verifies that all expectations of this gently instance have been satisfied. If not called manually, this method is called when the process 'exit'
event is fired.
If msg
is given, it will appear in any error that might be thrown.
Gently is licensed under the MIT license.
FAQs
<!-- badges/ --> [![Build Status](https://travis-ci.org/felixge/node-gently.svg?branch=master)](https://travis-ci.org/felixge/node-gently) [![npm](https://img.shields.io/npm/v/gently.svg)](https://www.npmjs.com/package/gently) [![Dependency Status](https
The npm package gently receives a total of 1,038 weekly downloads. As such, gently popularity was classified as popular.
We found that gently demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.