Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
jasmine-spy-helpers
Advanced tools
jasmine-spy-helpers adds some helper functions to Jasmine.
jasmine-spy-helpers is compatible with Jasmine 2.0+, but it will track with the current Jasmine version.
jasmine.spyAll(object)
callThrough
it('should spy all methods', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
}
};
jasmine.spyAll(obj);
expect(obj.method1).not.toHaveBeenCalled();
expect(obj.method2).not.toHaveBeenCalled();
});
jasmine.spyIf(function)
it('should spy method once', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
}
};
jasmine.spyIf(obj, 'method1');
jasmine.spyIf(obj, 'method1');
});
jasmine.spyAllExcept(object, [excepts])
callThrough
it('should spy selected method', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
}
};
jasmine.spyAllExcept(obj, 'method2');
});
jasmine.spyEach(object, [only])
callThrough
it('should spy selected method', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
},
method3: function() {
}
};
jasmine.spyEach(obj, ['method1', 'method2');
});
jasmine.resetAll(object)
it('should reset all methods', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
}
};
spyOn(obj, 'method1');
spyOn(obj, 'method2');
obj.method1();
obj.method2();
expect(obj.method1).toHaveBeenCalled();
expect(obj.method2).toHaveBeenCalled();
jasmine.resetAll(obj);
expect(obj.method1).not.toHaveBeenCalled();
expect(obj.method2).not.toHaveBeenCalled();
});
jasmine.resetEach(object, [methods])
it('should reset all methods', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
}
};
spyOn(obj, 'method1');
spyOn(obj, 'method2');
obj.method1();
obj.method2();
expect(obj.method1).toHaveBeenCalled();
expect(obj.method2).toHaveBeenCalled();
jasmine.resetEach(obj, ['method1']);
expect(obj.method1).not.toHaveBeenCalled();
expect(obj.method2).toHaveBeenCalled();
});
jasmine.resetAllExcept(object, [methods])
it('should reset all methods', function() {
var obj = {
id: 1,
method1: function() {
},
method2: function() {
}
};
spyOn(obj, 'method1');
spyOn(obj, 'method2');
obj.method1();
obj.method2();
expect(obj.method1).toHaveBeenCalled();
expect(obj.method2).toHaveBeenCalled();
jasmine.resetAllExcept(obj, ['method1']);
expect(obj.method1).toHaveBeenCalled();
expect(obj.method2).not.toHaveBeenCalled();
});
MIT License (MIT)
A lot of code was borrowed from jasmine-utils, but I was looking to create just the spy helpers.
Open to pull requests.
FAQs
Updated jasmine spy helpers for less boilerplate code.
The npm package jasmine-spy-helpers receives a total of 1 weekly downloads. As such, jasmine-spy-helpers popularity was classified as not popular.
We found that jasmine-spy-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.