javascript - 如何让 Karma html 记者在 karma conf 中工作?

标签 javascript git unit-testing karma-runner karma-jasmine

如何让 Karma html reporter 在 karma conf 中工作?

要运行我的单元测试,我输入:“npm run test”,测试在 git bash 中运行良好。 但我想在 reporter.html 文件中看到它们。

我在根目录中的 karma conf 文件旁边创建了一个 reporter.html 文件。 reporter.html 文件中没有任何内容。

我认为当我运行 npm run tests 时会填充 reporter.html 文件并且显示 reporter html 页面。但这不会发生。

这是位桶存储库的链接:https://bitbucket.org/snproject/

这是我的 karma session :

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

      basePath: '',

      frameworks: ['jasmine'],

      files: [
        {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
        {pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
        {pattern: 'node_modules/angular2/bundles/testing.js', included: true, watched: true},
        {pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true},
        {pattern: 'node_modules/angular2/bundles/http.js', included: true, watched: true},      
        {pattern: 'src/firebase/firebase.js', included: true, watched: true},  

        {pattern: 'karma-test-shim.js', included: true, watched: true},

        {pattern: 'src/**/*.js', included: false, watched: true},
        {pattern: 'src/**/*.html', included: false, watched: true},
        {pattern: 'src/**/*.css', included: false, watched: true},
        {pattern: 'src/**/*.ts', included: false, watched: false},
        {pattern: 'src/**/*.js.map', included: false, watched: false}
      ],

      proxies: {
        "/app/": "/base/src/app/"
      },

      reporters: ['progress', 'html'],

      //This doesnt seem to work or show up????
      htmlReporter: {
        outputFile: 'reporter.html'              
      },

      port: 9877,
      colors: true,
      logLevel: config.LOG_INFO,
      autoWatch: true,
      browsers: ['Chrome'],
      singleRun: false
    })
  }

最佳答案

如果您引用 karma-html-reporter页面,您可以看到 outputFile 不是报告者获得的选项之一。

显然,您无法决定输出文件的名称。您可以决定将结果保存在何处。默认情况下,报告者创建一个名为 karma_html 的文件夹,其中为每个浏览器/操作系统创建一个文件夹,其中包含一个包含测试结果的 index.html 文件。

查看您的存储库,看起来这个文件夹已创建(您甚至提交了它...),所以一切正常。

关于javascript - 如何让 Karma html 记者在 karma conf 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34152780/

相关文章:

javascript - 带参数的单元测试 AngularJs $resource 查询

apache-flex - git + Flash Builder 工作流程 : how do I set it up so git works smoothly?

linux - OpenShift 存储库的 Git 克隆在 Linux 中挂起,但在 Windows 中不挂起

python - 使用 HttpResponse 为函数编写 Django 单元测试

javascript - 仅订阅新条目或已删除条目的可观察数组

git - 将新分支推送到 google.com git 存储库

java - 对将序列化对象写入文件的方法进行单元测试

javascript - 查找元素在浏览器滚动中的位置

javascript - 在 Javascript 中将字符串连接到 Int

javascript - 登录是否存在检查 Angular JS