Jenkins与Jest的集成



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

我曾尝试将Jest与jasmine-reporter集成,但没有设法获得JUnit XML输出。我安装了茉莉1.3的记者与npm install jasmine-reporters@~1.0.0,然后在我的setupTestFrameworkScriptFile:

require('jasmine-reporters');
jasmine.VERBOSE = true;
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter({
  savePath: "output/"
}));

当我运行jest时,我得到NodeJS attempt: Arguments to path.join must be stringsNodeJS attempt: Object [object Object] has no method 'join'

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

您使用的是jasmine-reporter 2的语法。X和1。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) {
    /* ... */
}

看起来jest-junit也是一个选项

相关内容

  • 没有找到相关文章

最新更新