@cspell/cspell-junit-reporter
带有 JUnit XML 输出的 CSpell 通讯员
提供a J单位 兼容的 Cspell 运行的 XML 报告,适合 理解 JUnit 测试的 CI 系统(GitHub Actions, GitLab, Jenkins, CircleCI等)的消费 结果格式.
安装
将其安装为将使用它的数据库中的开发软件包 .
npm install -SD @cspell/cspell-junit-reporter
使用量
使用命令行
cspell . --reporter @cspell/cspell-junit-reporter
使用 CSpell 配置
将此添加到 cspell.yaml数字 :
reporters: [['@cspell/cspell-junit-reporter', { outFile: 'cspell-junit.xml' }]]
或者说 cspell.json
{
"reporters": [["@cspell/cspell-junit-reporter", { "outFile": "cspell-junit.xml" }]]
}
输出格式
@cspell/cspell-junit-reporter 将 cspell 运行到 JUnit XML 的地图如下 :
- 一个
<testsuites>整个运行的根元素 - 一个
<testsuite>每个文件检查, 以文件命名 - 一个
<testcase>每个在文件中找到的拼写问题,包含一个<failure>用拼错的字, 地点和消息 - 没有问题的文件只能通过
<testcase>这样套房就不会空了 - 跳过的文件获得一个单
<testcase>包含一个<skipped>元素 - 处理不与特定拼写问题相绑定的错误( 例如, 错误的配置文件) 是
专门报告
cspell-errors使用测试软件<error>改为<failure>
所有文件路径、单词和信件都会被逃脱,所以输出即使包含 XML 也是合法的
& < > " ' 字符键.
单个文件的示例输出, 包含一个问题:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="cspell" tests="1" failures="1" errors="0" time="0.001">
<testsuite name="src/example.ts" tests="1" failures="1" errors="0" time="0.001">
<testcase name="teh (3:5)" classname="src/example.ts">
<failure type="spelling" message="Unknown word: "teh"">Unknown word: "teh"</failure>
</testcase>
</testsuite>
</testsuites>
设置
可能的设置 :
outFile(默认: stdout) - XML 文件发出路径suiteName(默认 :cspell) - 根所使用的名称<testsuites>元素
记者设置
/**
* cspell-junit-reporter settings type definition
*/
export type CSpellJUnitReporterSettings = {
/**
* Path to the output JUnit XML file.
*
* Relative paths are relative to the current working directory.
*
* Special values:
* - `stdout` - write the XML to `stdout`.
* - `stderr` - write the XML to `stderr`.
*
* @default stdout
*/
outFile?: string;
/**
* Name to use for the root `<testsuites>` element.
*
* @default cspell
*/
suiteName?: string;
};