如何在VSTS测试中发布Jest单元测试结果

如何在VSTS测试中发布Jest单元测试结果

本文介绍了如何在VSTS测试中发布Jest单元测试结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一些针对版本的关于SO的问题以供开玩笑的单元测试在VSTS构建测试结果"选项卡中发布其结果.但是找不到适当的解决方案.

I've found some questions on SO specific to version for jest unit test to publish its result in VSTS build Test Results tab. But no proper solution is found.

推荐答案

我已经扔了一些有趣的npm软件包,例如 tap-xunit jest-json-to-tap,但无法确定它是否有效.以下步骤对我有用,以使结果可在测试VSTS 版本.

I've gone throw some jest npm packages like tap-xunit and jest-json-to-tap but couldn't figure out it to work. Following steps worked for me to get the results to review under Test of VSTS build.

  1. 安装 jest-trx-results-processor

# NPM
npm install jest-trx-results-processor --save-dev

# Yarn
yarn add -D jest-trx-results-processor

  • 创建具有以下内容的jestTrxProcessor.js文件:

    var builder = require('jest-trx-results-processor');
    var processor = builder({
        outputFile: 'jestTestresults.trx'
    });
    module.exports = processor;
    

  • 更新的package.json文件应如下所示:

  • Updated package.json file should look like:

    "devDependencies": {
        "jest": "^23.4.1",
        "jest-trx-results-processor": "0.0.7",
        "jsdom": "^11.12.0",
        ...
    },
    "scripts": {
        "test": "jest"
    },
    "jest": {
        ...,
        "testResultsProcessor": "./jestTrxProcessor.js"
    }
    

  • 添加npm npm test的VSTS构建任务.这将运行笑话测试并将结果发布到jestTestresults.trx

  • Add npm task to VSTS build for npm test. This will run jest tests and publish results to jestTestresults.trx

    您将能够看到JEST测试以及其他测试.

    You will be able to see JEST tests along with other tests.

    这篇关于如何在VSTS测试中发布Jest单元测试结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 08-12 16:10