当我使用node直接调用index.js时,它可以工作,但当我运行mocha测试时,任务失败,并显示“必须初始化”错误消息。
my tasks index.ts如下所示:
import * as path from "path";
import tl = require('azure-pipelines-task-lib/task');
import trm = require('azure-pipelines-task-lib/toolrunner');
import os = require('os');
async function run() {
try {
const libmanJson = tl.getPathInput('libmanjson', true, true); //this throws
}
catch (err) {
console.log(err.message);
tl.setResult(tl.TaskResult.Failed, err.message);
}
}从此处复制mocha tests:docs.microsoft.com: Add a build or release task
发布于 2019-07-18 07:53:19
遇到同样的问题,通过向TaskMockRunner提供答案得到解决
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"which": {
"echo": "/mocked/tools/echo"
},
"exec": {
"/mocked/tools/echo Hello, from task!": {
"code": 0,
"stdout": "atool output here",
"stderr": "atool with this stderr output"
}
}
};
tmr.setAnswers(a)https://stackoverflow.com/questions/54709591
复制相似问题