我需要嘲笑&mkdirp-promise'暴露构造函数的节点模块,如下所示
mkdirpPromise(dirPath)
.then(() => {
console.log('ABCDEFGH');
resolve(dirPath);
})
.catch((error) => {
console.log('HeABCDEFGHre');
const details = error.message;
const err = customError.failed_create_downloads_directory()
.withDetails(details);
reject(err);
});
我能够首次使用proxiquire模拟它: -
let mkdirpPromiseMock = sinon.stub().rejects();
const sthreeDownloadMock =
proxyquire('./../../modules/sThreeDownload', {
joi: joiMock,
fs: fsMock,
'@monotype/core-error': {
errors: {
ApiError: customErrorMock,
},
},
'aws-sdk': awsSDK,
'mkdirp-promise': mkdirpPromiseMock,
path: pathMock,
});
现在我想用第二个测试用例
覆盖mkdirpPromiseMockmkdirpPromiseMock = sinon.stub().resolves();
我无法做到。任何帮助表示赞赏。
答案 0 :(得分:-1)