jest-feishu-reporter
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

jest-feishu-reporter

ci npm Size

将 Jest 的测试错误发送到飞书。

飞书自定义机器人使用说明: 如何在群组中使用机器人?

加群

安装

npm install -D jest-feishu-reporter
# 或者
yarn add -D jest-feishu-reporter

使用

jest.config.js 中配置:

module.exports = {
  reporters: [
    "default",
    // ... other reporters
    [
      "jest-feishu-reporter",
      {
        "token": "xxxxxx-xxxxxxx-xxxx-xxxx",
        "secret": "xxxxxxx",
      },
    ],
  ],
};

或者在 package.json 配置:

"jest": {
  "reporters": [
    "default",
    [
      "jest-feishu-reporter",
      {
        "token": "xxxxxx-xxxxxxx-xxxx-xxxx",
        "secret": "xxxxxxx"
      }
    ] 
  ]
}

package.json 中还可以单独配置:

"jest-feishu": {
  "token": "xxxxxx-xxxxxxx-xxxx-xxxx",
  "secret": "xxxxxxx"
}

配置说明

token

如何在群组中使用机器人?第二步可以获取机器人的 webhook 地址,格式如下:

​https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxx​
                                             ^^^^^^^^^^^^^^^^^
                                                   token

token 就是 url 最后面的部分。

secret

飞书有 3 种安全模式,如果使用签名校验,则需要设置 secret

注意事项

对于公有仓库,还可以通过设置系统环境变量来进行配置。

  • JEST_FEISHU_TOKEN - 设置 token
  • JEST_FEISHU_SECRET - 设置 secret

使用:

JEST_FEISHU_TOKEN=xxxx-xxxx-xxx npm run test

Github Actions 配置:

- name: Test
  env:
    JEST_FEISHU_TOKEN: ${{ secrets.FEISHU_TOKEN }}
  run: yarn test

License

jest-feishu-reporter is released under the MIT License. See the bundled LICENSE file for details.

Package Sidebar

Install

npm i jest-feishu-reporter

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

12.1 kB

Total Files

9

Last publish

Collaborators

  • iamjjc