我正在尝试在节点js上进行测试,我想模拟将要进行单元测试的函数之外的变量。例如
const sample = [];
function uploadDoc {
sample.push('fileLocation')
}
function toSave(){
for (i=0;i<sample.length;i++)
**some process read and access doc
}
我在对第二个功能进行单元测试时遇到问题我已经尝试重新连接npm,但也无法正常工作
const sample = [];
function uploadDoc {
sample.push('fileLocation')
}
function toSave(){
uploadDoc();
for (var i=0;i<sample.length;i++)
**some process read and access doc
}
Programming likes this will work,You should call uploadDoc firstly;