这是我定义我的函数并使用 module.exports 导出它们的地方
class GITHelper extends Helper {
addLatestReport(){
simpleGitPromise.addRemote(date,remote);
return simpleGitPromise.add('.')
.then(
(addSuccess) => {
console.log(addSuccess);
}, (failedAdd) => {
console.log('adding files failed');
});
}
commitLatestReport(){
console.log("Committing...");
return simpleGit.commit("Latest output from Automated UI Testing", "./output");
}
pushLatestReport() {
console.log('Pushing...');
return simpleGit.push(remote);
}
}
module.exports = GITHelper;
我需要在另一个节点依赖文件(mochawesome)中使用这个模块
var gitHelper = require('../../../helpers/GITHelper.js');
然后我像这样调用函数:
async function gitSender()
{
await gitHelper.addLatestReport();
await gitHelper.commitLatestReport();
await gitHelper.pushlatestReport();
console.log("Upload completed");
}
“TypeError:gitHelper.addLatestReport 不是函数”
这些不是定义的功能吗?它们没有正确导出吗?