我在 github 上有一个项目,它有大量的单元测试(使用 mocha for node.js)。
我想通过在每一页上展示那些通过/不及格的测试来炫耀一下。我注意到 Github 上的其他项目也在这么做。
我找不到任何关于如何显示测试状态的文档。
Take a look at Travis CI. You can use it with GitHub.
They have docs on using NodeJS
Those badges you see are called "status images" and Travis provides MarkDown that you can insert into your project's README.md file.
Note that since April 26th 2013, you can see the build status on your GitHub repo branch page:
The Commit Status API allows you to use that elsewhere: see " Repo Statuses API".
Starting April 30th, 2013, the API endpoint for commit statuses has been extended to allow branch and tag names, as well as commit SHAs.
CircleCI the status badges are also simply images that you can drop into your README.md file with the markdown. For example:
README.md
![Build Status](https://circleci.com/gh/<your github name>/<repo name>.png?circle-token=:circle-token)
or
![Build Status](https://circleci.com/gh/<your github name>/<repo name>.svg?style=shield&circle-token=:circle-token)
GitHub also has workflow status badges for GitHub Actions.
The image is usually embedded into the README.md file using Markdown like this:
![example workflow](https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW>.yml/badge.svg)