【问题标题】:karma-junit-reporter not recognized业力-junit-reporter 无法识别
【发布时间】:2016-08-28 04:45:54
【问题描述】:

我正在尝试使用 karma 运行测试并生成报告。我已经安装了 karma-junit-reporter,但在命令行上不断收到以下消息:

Cannot find plugin "karma-junit-reporter"

Can not load "junit", it is not registered

我的 karma.config.js:

plugins : [
    'karma-jasmine',
    'karma-junit-reporter',
    'karma-phantomjs-launcher'
]

我的 package.json:

"devDependencies": {
  "grunt": "0.4.5",
  "grunt-cli": "0.1.13",
  "grunt-env": "0.4.2",
  "grunt-exec": "0.4.6",
  "grunt-jasmine-node": "0.2.1",
  "grunt-jasmine-node-coverage": "0.1.10",
  "grunt-jscs": "1.8.0",
  "grunt-karma": "0.11.2",
  "jasmine-core": "2.3.4",
  "jasmine-node": "1.14.3",
  "jasmine-reporters": "0.4.1",
  "jscs": "1.13.1",
  "jshint": "2.4.4",
  "karma": "0.12.37",
  "karma-jasmine": "0.3.6",
  "karma-junit-reporter": "0.2.2",
  "karma-phantomjs-launcher": "0.2.0",
  "phantomjs": "1.9.17",
  "supertest": "0.9.0"
}

【问题讨论】:

  • 你最近跑过npm install吗?列出一个包并不能保证它已安装。
  • 我没有看到像reporters: ['progress', 'junit'] 这样的行你添加了它并且它有效吗?

标签: javascript junit jasmine karma-runner


【解决方案1】:

确保您运行了npm install,并且所有插件依赖项都在您的 package.json 中,就像提到的 @ssube 一样,这是一个很好的起点。话虽如此,这对我有用:

  module.exports = function (config) {
    config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    browsers: ["PhantomJS"],

    frameworks: ["jasmine-jquery" ,"jasmine"],

    files: [
        {
            pattern: "test/**/*.html",
            included: false,
            served: true,
            watched: true
        },
        "dist/latest/phone.min.js",
        "node_modules/jquery/dist/jquery.js"
        {
            pattern: "test/functional/test/phoneTest.js",
            watched: true
        }
    ], plugins: [
        "karma-jasmine-jquery",
        "karma-phantomjs-launcher",
        "karma-junit-reporter",
        "karma-jasmine"
    ],

    client: {
        "captureConsole": true
    },

    phantomjsLauncher: {
        // Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom) 
        exitOnResourceError: true
    },

    singleRun: true,

    reporters: ['progress', 'junit'],

    junitReporter: {
        outputDir: "testResults",
        outputFile: "FUNCTIONAL-TEST-results.xml"
    }
 });
};

【讨论】:

  • 可以在outputFile: 中添加多个文件吗?如何选择多个输出文件?
猜你喜欢
  • 2017-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多