How do I mock or stub process.argv
so that it can return a specific argument?
I tried using Sinon.js like this:
beforeEach(
() => {
sandbox.stub(
process.argv.slice(2)[0], 'C:\\home\\project\\assignment'
).value('--local');
}
);
afterEach(
() => {
sandbox.restore();
}
);
test(
'it replace value of node argument',
() => {
assert(process.argv.slice(2)[0], '--local');
}
);
But I keep getting an error that says trying to stub property 'C:\\home\\project\\assignment'
of undefined
.