In 05/09/2022, Github Actions released $GITHUB_STEP_SUMMARY
.
I use it for reporting code coverage. Writing it in a comment will always fail as comments cannot be greater than 65536 characters. I always exceed that.
Add this step to your Github Actions file, if you use vitest:
- name: 🧪 Test
run: |
yarn test --silent --coverage
echo "### Test Results 🧪 " >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
yarn c8 report >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
If you use jest, just replace yarn c8 report
with the output of yarn test --silent --coverage
, like so:
- name: 🧪 Test
run: |
echo "### Test Results 🧪 " >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
yarn test --silent --coverage >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
However, you won’t be able to see your tests run in Github Actions as they will be piped to the ENV variable. 🤔