playwright-cucumber-ctrf-generator
Version:
Convert Cucumber JSON reports into CTRF Markdown reports for Playwright
110 lines (84 loc) • 3.7 kB
Markdown
# Playwright Cucumber JSON CTRF Generator (Beta)

**Playwright Cucumber JSON CTRF Generator** is a command-line tool that converts **Cucumber JSON reports** into a clean, readable **Markdown test report**. It is particularly useful for projects using Playwright, Cucumber, or similar testing frameworks to generate structured test summaries.
## 📢 Beta Notice
This package is currently in **Beta stage**. While it is functional, there may be minor issues or improvements required.
## Features 🚀
- 📊 **Summary at the Top**: View total scenarios, passed, failed, and skipped counts immediately.
- ✅ **Readable Reports**: Generates human-friendly Markdown reports from Cucumber JSON output.
- 🛠️ **Easy Integration**: Works seamlessly with Playwright and Cucumber frameworks.
## How to use?
1. **Install the package**:
```bash
npm install playwright-cucumber-ctrf-generator
```
2. **Add the script** in your `package.json`:
```json
"scripts": {
"generate:ctrf": "cucumber-ctrf-generator ./test-result/cucumber-report/cucumber-report.json ctrf-report.md"
}
```
Make sure your `cucumber-report.json` file is specified correctly.
3. **Integrate in GitHub Workflow**:
Below is an example of a GitHub Actions workflow file for Playwright tests:
```yaml
name: Playwright Tests
on:
workflow_dispatch:
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Start Test Execution Timer
id: start_time
run: echo "start_time=$(date +%s)" >> $GITHUB_ENV
- name: Run Playwright Cucumber tests
run: |
npm run execute:tests
if grep -q '"status": "failed"' test-result/cucumber-report/cucumber-report.json; then
echo "Cucumber scenarios failed."
exit 1
fi
- name: Calculate Total Test Duration
if: ${{ always() }}
id: end_time
run: |
end_time=$(date +%s)
duration=$((end_time - $start_time))
echo "total_duration=${duration}" >> $GITHUB_ENV
echo "Total Test Duration: $((duration / 60))m $((duration % 60))s"
- name: Upload Playwright Cucumber Report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: Cucumber Reports
path: test-result/cucumber-report
retention-days: 30
- name: Generate CTRF Report
if: ${{ always() }}
run: |
npm run generate:ctrf
- name: Add CTRF Report to GitHub Actions Summary
if: ${{ always() }}
run: |
echo "## ⏰ Total Execution Duration : $((total_duration / 60))m $((total_duration % 60))s" >> $GITHUB_STEP_SUMMARY
cat ./ctrf-report.md >> $GITHUB_STEP_SUMMARY
```
## Sample Report in GitHub Actions
Here is a sample screenshot of the generated report:
<img src="https://i.ibb.co/XXNCW4q/Output.png" alt="Sample CTRF Report Screenshot" width="600" />
Now you can effortlessly generate clean and readable reports for your Playwright Cucumber projects! 🎉