Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jenkins与Jest的整合_Javascript_Jasmine_Jestjs - Fatal编程技术网

Javascript Jenkins与Jest的整合

Javascript Jenkins与Jest的整合,javascript,jasmine,jestjs,Javascript,Jasmine,Jestjs,有没有办法将Jenkins集成到构建在Jasmine之上的Javascript Jest测试框架中 我尝试将Jest与集成,但未能获得JUnitXML输出。我使用npm install Jasmine reporters@~1.0.0安装了Jasmine 1.3的报告程序,然后在我的setupTestFrameworkScriptFile中: require('jasmine-reporters'); jasmine.VERBOSE = true; jasmine.getEnv().addR

有没有办法将Jenkins集成到构建在Jasmine之上的Javascript Jest测试框架中

我尝试将Jest与集成,但未能获得JUnitXML输出。我使用
npm install Jasmine reporters@~1.0.0
安装了Jasmine 1.3的报告程序,然后在我的
setupTestFrameworkScriptFile
中:

require('jasmine-reporters');

jasmine.VERBOSE = true;

jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter({
  savePath: "output/"
}));

当我运行
jest
时,我得到
NodeJS尝试:path.join的参数必须是字符串
NodeJS尝试:Object[Object Object]没有方法“join”
您在1.x分支中使用的是jasmine reporters 2.x的语法。具体来说,您正在传递一个选项对象,但需要发送位置参数

不要这样做:

jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter({
  savePath: "output/"
}));
相反,您应该这样做:

jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter("output/"));
您可以查看可用选项列表。以下是当前的选项:

/**
 * Generates JUnit XML for the given spec run.
 * Allows the test results to be used in java based CI
 * systems like CruiseControl and Hudson.
 *
 * @param {string} [savePath] where to save the files
 * @param {boolean} [consolidate] whether to save nested describes within the
 *                  same file as their parent; default: true
 * @param {boolean} [useDotNotation] whether to separate suite names with
 *                  dots rather than spaces (ie "Class.init" not
 *                  "Class init"); default: true
 * @param {string} [filePrefix] is the string value that is prepended to the
 *                 xml output file; default: 'TEST-'
 * @param {boolean} [consolidateAll] whether to save test results from different
 *                  specs all in a single file; filePrefix is then the whole file
 *                  name without extension; default: false
 */
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation, filePrefix, consolidateAll) {
    /* ... */
}

我已经设法得到了一个在这个工作版本。问题是我没有在测试文件中模拟
path
fs

看起来也是一个选项。

谢谢提示,但它仍然不起作用,并且给出了相同的错误。谢谢你的示例应用程序,我可以重现你的错误,尽管原因对我来说没有意义。看起来,通过NodeJS
require
加载的变量不知怎么搞混了。我不知道为什么,到目前为止,我只在
jest
环境中见过这种情况。我用观察到的行为评论了您在jest存储库中打开的问题。