Ami*_*ole 40 javascript unit-testing karma-runner
当我在我的webapp上运行业力时,我只获得通过测试传递的通用消息 - 有没有办法获得通过测试的列表?如何获得更详细的输出?
我在文档中的任何地方都找不到这个.
ben*_*ope 50
我知道怎么做!
Karma的终端输出来自名为Reporters的对象.Karma附带一些内置记者(可以在其中找到karma/lib/reporters).Karma也可以使用自定义记者.
您可以指定项目karma.config.js文件中使用的记者.
例如,'dots'报告者只是在每次测试通过时打印一个点:
reporters: ['dots'],
Run Code Online (Sandbox Code Playgroud)
'进步'记者打印的不仅仅是点:
reporters: ['progress'],
Run Code Online (Sandbox Code Playgroud)
当测试成功或失败时,自定义报告者karma-spec-reporter会打印每个测试的名称(但不是很多):
reporters: ['spec'],
Run Code Online (Sandbox Code Playgroud)
你可能想要推销自己的记者,因为karma-junit-reporter,karma-spec-reporter和包含的记者可能无法满足你的需求.
我猜测定制karma-spec-reporter是这种情况下的最佳选择,因为它在测试成功时已经打印了一行.
如果您正在寻找更简单易用的东西,这里是我建立的自定义记者.它报告没有终端颜色的传递和失败测试.
Mat*_*att 41
我推荐Karma Spec Reporter.这将为您提供一个漂亮的单元测试报告.
如何使用它:
在项目的命令行中,
npm install karma-spec-reporter --save-dev
在
karma.conf.js,Run Code Online (Sandbox Code Playgroud)... 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"], ...
就这些.请享用.
| 归档时间: |
|
| 查看次数: |
21040 次 |
| 最近记录: |