Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
An asynchronous mock clock library for javascript unit testing.
npm install mock-clock --save-dev
This library allows you to mock the clock in your Javascript unit tests, giving you more control over the value of the current time and the behavior of timers.
Unlike other implementations, ticking the clock is always an async operation. When testing code that mixes Promises and timer behavior, it can be difficult (and potentially undesirable) to truly flatten all behavior into a synchronous path.
Let's jump into an example...
var clock = require('mock-clock');
describe('my tests', function () {
beforeEach(clock.install);
afterEach(clock.uninstall);
it('runs something every 500ms', function (done) {
var frames = [];
setInterval(function () {
frames.push(true);
}, 500);
expect(frames).toEqual([]);
clock.tick(499).then(function () {
expect(frames).toEqual([]);
return clock.tick(1);
}).then(function () {
expect(frames).toEqual([true]);
}).then(clock.ticks(500)).then(function () {
expect(frames).toEqual([true, true]);
done();
});
});
});
WIP
Licensed under MIT. Full license here »
Pull requests are welcome. Make sure to include tests for any new or modified functionality.
Feature requests and issue reports are also welcome. When reporting an issue be sure to include operating system, node version, and any other information required to reproduce the problem.
FAQs
An asynchronous mock clock library for javascript unit testing
The npm package mock-clock receives a total of 4 weekly downloads. As such, mock-clock popularity was classified as not popular.
We found that mock-clock 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.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.