
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
depends-on
Advanced tools
Spins up external processes your tests need. Think of it as async.auto
with process control for integration tests.
{
"redis": {
"cmd": ["/usr/sbin/redis-server"],
"wait_for": {
"port": 6379
}
}
}
var ready = require('depends-on')('redis');
var test = require('tape');
test('init dependencies for ' + __filename, ready);
< … tests that use redis here … >
ready()
is a function that takes a callback (or a tape test object). It will call that callback when your dependencies are ready. They'll be stopped when your node process exits.
Dependencies can have dependencies. Say you want to clear all values from Redis after it starts, but before your tests run:
{
"redis-server": {
"cmd": ["/usr/sbin/redis-server"],
"wait_for": {
"port": 6379
}
},
"fresh & clean redis": {
"cmd": ["./bin/flushall.sh"],
"depends": ["redis-server"],
"wait_for": {
"exit_code": 0
}
}
}
var ready = require('depends-on')('fresh & clean redis');
var test = require('tape');
test('start fresh redis', ready);
test('test that uses redis', function(t) {
…
});
…
If multiple tests are require()
d and share dependencies, depends-on will share them across the test files, each dependency only being started once. When node exits, all dependencies will exit.
dependencies.json
is a file containing a json object mapping dependency names to objects that describe each dependency.
One of port
or exit_code
is required to use wait_for
.
Just for fun, bin/graph-dependencies.js
can graph the dependencies in your project with graphviz.
dot -Tpng -odeps.png <(./bin/graph-dependencies.js) && open deps.png
->
Be sure to require('depends-on')
before you require('tape')
. Like this:
var ready = require('depends-on')('something');
var test = require('tape');
Both depends-on and tape have process.on('exit', …)
handlers, but tape calls process.exit
in its process.on('exit', …)
handler, so if tape's handler runs first, depends-on's handler will never run (and child processes won't be cleaned up). Handlers run in the order they are added, so depends-on must be required first.
I like to be able to run integration tests individually like $ node tests.js
without running anything else or relying on some external service coincidentally being on.
FAQs
Spins up external processes your tests need
The npm package depends-on receives a total of 3 weekly downloads. As such, depends-on popularity was classified as not popular.
We found that depends-on 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
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.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.