
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Quibble is sorta like proxyquire,
sandboxed-module and
mockery. Using quibble
you can replace
how require
will behave for a given path, with its intended use being almost
solely unit testing.
Say we're testing pants:
quibble = require('quibble')
describe('pants', function(){
var subject, legs;
beforeEach(function(){
legs = quibble('./../lib/legs', function(){ return 'a leg';});
subject = require('./../lib/pants');
});
it('contains legs', function() {
expect(subject().left).toContain('a leg')
expect(subject().right).toContain('a leg')
})
});
That way, when the subject
loaded from lib/pants
runs require('./legs')
,
it will get back the function that returns 'a leg'
. The fake value is also
returned by quibble
, which makes it easy to set and assign a test double in a
one-liner.
For more info on how this module is really intended to be used, check out its inclusion in testdouble.js
There's only one option: what you want to do with quibbled modules by default.
Say you're pulling in testdouble.js and you want every quibbled module to default to a single test double function with a name that matches its absolute path. You could do this:
quibble = require('quibble')
beforeEach(function(){
quibble.config({
defaultFakeCreator: function(path) {
return require('testdouble').create(path);
}
});
});
With this set up, running quibble('./some/path')
will default to replacing all
require('../anything/that/matches/some/path')
invocations with a test double named
after the absolute path resolved to by './some/path'
.
Spiffy!
A few things that stand out about quibble:
require
just as you normally would). The instantiation
style of other libs is a little different (e.g. require('./my/subject', {'/this/thing': stub})
reset()
method that undoes everything, intended to be run afterEach
test runsFAQs
Makes it easy to replace require'd dependencies.
The npm package quibble receives a total of 83,672 weekly downloads. As such, quibble popularity was classified as popular.
We found that quibble demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.