Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/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 如何从karma runner suite获得通过测试的列表?_Javascript_Unit Testing_Karma Runner - Fatal编程技术网

Javascript 如何从karma runner suite获得通过测试的列表?

Javascript 如何从karma runner suite获得通过测试的列表?,javascript,unit-testing,karma-runner,Javascript,Unit Testing,Karma Runner,当我在我的webapp上运行karma时,我只会收到诸如测试通过之类的一般消息-有没有办法获得通过测试的列表?如何获得更详细的输出 我在文档中找不到这一点。将此插件与karma 0.9.0或更高版本一起使用 您可以将日志添加到测试规范中。请查看log4js节点: 我知道如何做到这一点 业力的终端输出来自被称为记者的物体。Karma附带一些内置的报告器(可以在Karma/lib/Reporters中找到)。因果报应也可以使用定制记者 您可以指定在项目的karma.config.js文件中使用哪些报

当我在我的webapp上运行karma时,我只会收到诸如测试通过之类的一般消息-有没有办法获得通过测试的列表?如何获得更详细的输出


我在文档中找不到这一点。

将此插件与karma 0.9.0或更高版本一起使用


您可以将日志添加到测试规范中。请查看log4js节点:


我知道如何做到这一点

业力的终端输出来自被称为记者的物体。Karma附带一些内置的报告器(可以在
Karma/lib/Reporters
中找到)。因果报应也可以使用定制记者

您可以指定在项目的
karma.config.js
文件中使用哪些报告器

例如,“dots”报告器仅在每个测试通过时打印一个点:

reporters: ['dots'],
“progress”reporter打印的不仅仅是点:

reporters: ['progress'],
当测试成功或失败时,定制报告器打印每个测试的名称(但不包括其他内容):

您可能想要滚动您自己的记者,因为karma junit reporter、karma spec reporter和包含的记者可能无法满足您的需求

我猜在这种情况下,定制karma spec reporter是最好的选择,因为它已经在测试成功时打印了一行


如果你想找一个更简单的工作平台,我创建了一个定制的reporter。它报告通过和失败的测试,没有终端颜色。

我推荐Karma Spec Reporter。这会给你一个漂亮的单元测试报告

如何使用它:

  • 安装Karma Spec Reporter
  • 在项目的命令行上

    npm安装karma spec reporter——保存开发人员

  • 将Karma Spec Reporter添加到配置中
  • karma.conf.js

    ...
      config.set({
      ...
        reporters: ["spec"],
        specReporter: {
          maxLogLines: 5,         // limit number of lines logged per test
          suppressErrorSummary: true,  // do not print error summary
          suppressFailed: false,  // do not print information about failed tests
          suppressPassed: false,  // do not print information about passed tests
          suppressSkipped: true,  // do not print information about skipped tests
          showSpecTiming: false // print the time elapsed for each spec
        },
        plugins: ["karma-spec-reporter"],
      ...
    

    仅此而已。享受。

    通过
    npm安装karma spec reporter——保存开发版本来安装karma spec reporter的相关功能。希望这对我不清楚如何使用的人有所帮助。谢谢@AnsonKao还需要在
    karma.conf
    Hi@Matt的插件部分指定
    karma spec reporter
    ,我按照说明进行操作,但是当我运行ng测试时,我看到了相同的界面,您是如何获得图像中显示的格式的
    ...
      config.set({
      ...
        reporters: ["spec"],
        specReporter: {
          maxLogLines: 5,         // limit number of lines logged per test
          suppressErrorSummary: true,  // do not print error summary
          suppressFailed: false,  // do not print information about failed tests
          suppressPassed: false,  // do not print information about passed tests
          suppressSkipped: true,  // do not print information about skipped tests
          showSpecTiming: false // print the time elapsed for each spec
        },
        plugins: ["karma-spec-reporter"],
      ...