
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
execa_test_double
Advanced tools
execaWith this library you can build test doubles for
process execution with execa.
npm install execa_test_double
Inline stubbing with mockery:
const execaTestDouble = require('execa_test_double');
const mockery = require('mockery');
(async () => {
execaTestDouble.createStub([{
command: "echo hello world",
exitCode: 0,
stdout: "hello world",
stderr: ""
}]);
mockery.registerMock('execa', execaTestDouble.execa);
mockery.enable({useCleanCache: true});
//expected output `hello world`
const execa = require('execa');
console.log(await execa('echo', ['hello', 'world']));
mockery.disable();
mockery.deregisterAll();
})();
Stubbed invocations can be verified with the getStub() function:
const execaTestDouble = require('execa_test_double');
const mockery = require('mockery');
(async () => {
execaTestDouble.createStub([{
command: "echo hello world",
exitCode: 0,
stdout: "hello world",
stderr: ""
}]);
mockery.registerMock('execa', execaTestDouble.execa);
mockery.enable({useCleanCache: true});
const execa = require('execa');
console.log(await execa('echo', ['hello', 'world']));
assert.true(execaTestDouble.getStub().withArgs('echo hello world').calledOnce);
mockery.disable();
mockery.deregisterAll();
})();
The verification methods of sinon spies can be used.
Creates stubs for processes. For processes a array with
the type childProcessResult is expected.
For an successful execution please supply the following properties:
{
// command (file and arguments)
command: "echo hello world",
exitCode: 0,
stdout: "hello world",
stderr: ""
}
For an command, which terminates with exitCode !== 0:
{
command: "terminate",
exitCode: 1,
exitCodeName: "EPERM",
stdout: "",
stderr: "terminated"
}
For an unknown file:
{
command: "unknown",
exitCodeName: "ENOENT"
}
The stub behavior is reseted at every invocation of this method. The real command is executed, if it isn't stubbed.
Reads the stubs from JSON-Files (JSON-Array or JSON-Object).
Globby is used for path
filtering. The parameter globs and options are
directly passed to globby.
The stub behavior is reseted at every invocation of this method. The real command is executed, if it isn't stubbed.
Resets the history and the behavior of the stub.
Returns the sinon stub.
The major and minor component of the version number
will be keeped in sync with execa.
FAQs
Test doubles for process execution with execa
We found that execa_test_double 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.