@ednaaaj/jira-test
v1.0.5
Published
CLI tool that connects Jira issues to automated tests and runs them locally
Maintainers
Readme
jira-test
Run your test files and automatically post coverage to Jira tickets.
A CLI tool that runs test files, collects coverage, and posts results directly to Jira tickets with beautiful formatted comments.
✨ Features
- 🎯 File-Based Testing: Simply run
jira-test MyComponent.test.tsx - 🔍 Auto-Detection: Automatically finds Jira ticket from describe blocks
- 🧪 Test Runner Detection: Supports Jest, Vitest, Mocha (auto-detected from package.json)
- 📊 Coverage Reporting: Posts component coverage directly to Jira tickets
- 📋 Subtask Matching: Shows which Jira subtasks have tests in your file
- 🎨 Beautiful Formatting: Rich Jira comments with tables, colors, and status badges
- ⚡ Animated Spinners: Real-time progress indicators
- 🔒 Flexible Auth: Supports Jira Cloud and Data Center/Server
- 🚫 No Plugins: Works with standard Jira without Xray/Zephyr
📦 Installation
# Install globally
npm install -g @ednaaaj/jira-test
# Or use npx
npx @ednaaaj/jira-test MyComponent.test.tsx🚀 Quick Start
1. Set up environment variables
# For Jira Cloud
export JIRA_BASE_URL="https://your-domain.atlassian.net"
export JIRA_EMAIL="[email protected]"
export JIRA_API_TOKEN="your-api-token"
# For Jira Data Center/Server
export JIRA_BASE_URL="https://jira.your-company.com"
export JIRA_PAT="your-personal-access-token"Get your Jira API token: https://id.atlassian.com/manage-profile/security/api-tokens
2. Add Jira ticket to your test file
// HotelBanner.test.tsx
describe('HOTEL-27752', () => {
it('renders banner correctly', () => {
// your test
});
});3. Run the test
jira-test HotelBanner.test.tsxThat's it! The tool will:
- ✅ Auto-detect the Jira ticket (HOTEL-27752) from your describe block
- ✅ Auto-detect your test runner (Jest/Vitest/Mocha)
- ✅ Run tests with coverage
- ✅ Post results and coverage to HOTEL-27752
📖 Usage
File Mode (Recommended)
Run a specific test file:
jira-test path/to/MyComponent.test.tsxThe tool will:
- Find the Jira ticket key from
describe('TICKET-123', ...)in your file - Detect your test runner from package.json
- Run tests with coverage for that file only
- Fetch subtasks from Jira
- Post a comment to the Jira ticket with:
- Test run summary (X tests ran, Y passed, Z failed)
- Subtask matching table (which subtasks have tests in the file)
- Component coverage table (coverage for the component being tested)
Options
jira-test MyComponent.test.tsx --no-comment # Run without posting to Jira
jira-test MyComponent.test.tsx --dry # Preview without running testsWhat Gets Posted to Jira
When you run jira-test HotelBanner.test.tsx, it posts a comment like this:
🧪 Test Run Summary
12 tests ran — 12 passed · 0 failed
📋 Subtask Matching
┌──────────────┬─────────────────────────────────┬───────────────────┐
│ Subtask │ Title │ Status │
├──────────────┼─────────────────────────────────┼───────────────────┤
│ HOTEL-27988 │ Verify banner is displayed │ ✅ Found in file │
│ HOTEL-27989 │ Verify banner JSON structure │ ⚠️ Not found │
└──────────────┴─────────────────────────────────┴───────────────────┘
🎯 Component Coverage
┌──────────────────┬────────────┬──────────┬───────────┬───────┐
│ File │ Statements │ Branches │ Functions │ Lines │
├──────────────────┼────────────┼──────────┼───────────┼───────┤
│ HotelBanner.tsx │ 71.66% │ 50% │ 71.42% │ 73.21%│
└──────────────────┴────────────┴──────────┴───────────┴───────┘🔧 Advanced Usage
Legacy Mode (Run by Jira Key)
You can still run tests by Jira key directly:
jira-test run HOTEL-27752This mode:
- Fetches the ticket and subtasks from Jira
- Runs all tests matching
describe('HOTEL-27752', ...) - Posts coverage to the ticket
Options for Legacy Mode
| Option | Description | Default |
|--------|-------------|---------|
| --platform <web\|mobile\|all> | Filter test cases by platform label | all |
| --link-type <name> | Jira link type for test case links | "is tested by" |
| --mode <mode> | ticket-key or title matching | ticket-key |
| --jest-cmd <command> | Test command to run | jest |
| --repo <path> | Repository root path | current directory |
| --no-comment | Disable posting to Jira | posts by default |
Examples
# File mode (recommended)
jira-test src/components/Button.test.tsx
# Run without posting to Jira
jira-test Button.test.tsx --no-comment
# Legacy mode - run by ticket key
jira-test run HOTEL-27752
# Legacy mode with custom Jest command
jira-test run HOTEL-27752 --jest-cmd "turbo test --filter=./packages/hotels --"
# Preview what would run
jira-test run HOTEL-27752 --dry🎯 How It Works
File Mode Workflow
- Parse Test File: Extracts Jira ticket key from
describe('TICKET-123', ...) - Detect Test Runner: Checks package.json for jest/vitest/mocha
- Run Tests: Executes test file with coverage
- Fetch Jira Data: Gets ticket and subtasks from Jira API
- Match Subtasks: Compares Jira subtask titles with test names
- Filter Coverage: Shows only the component file being tested
- Post to Jira: Creates formatted comment with results and coverage
Auto-Detection
Test Runner Detection (checks package.json dependencies):
- Jest:
jestor@jest/core - Vitest:
vitest - Mocha:
mocha
Jira Ticket Detection (from describe blocks):
describe('TICKET-123', () => { ... }) // ✅ Detects TICKET-123
describe('HOTEL-456', () => { ... }) // ✅ Detects HOTEL-456Coverage Filtering
The tool intelligently filters coverage to show only relevant files:
# Running: jira-test HotelBanner.test.tsx
# Shows coverage for: HotelBanner.tsx only
# Hides: All other project files📋 Subtask Matching
The tool compares Jira subtasks with tests in your file:
| Subtask Title | Test Name | Status |
|--------------|-----------|--------|
| "Verify banner displays correctly" | it('Verify banner displays correctly', ...) | ✅ Found |
| "Verify banner has 3 dots" | No matching test | ⚠️ Not found |
This helps you track which subtasks have test coverage!
🚨 Exit Codes
| Code | Meaning |
|------|---------|
| 0 | All tests passed |
| 1 | One or more tests failed |
| 2 | Configuration error (missing env vars, invalid file) |
| 3 | Jira API error (auth failed, issue not found) |
🔐 Environment Variables
Required
JIRA_BASE_URL: Your Jira instance URL- Jira Cloud:
https://your-domain.atlassian.net - Jira Server:
https://jira.your-company.com
- Jira Cloud:
Authentication (choose one)
Jira Cloud:
export JIRA_EMAIL="[email protected]"
export JIRA_API_TOKEN="your-api-token"Jira Data Center/Server:
export JIRA_PAT="your-personal-access-token"🐛 Troubleshooting
"No Jira ticket found in test file"
Make sure your describe block includes a Jira ticket:
// ❌ Won't work
describe('HotelBanner tests', () => { ... })
// ✅ Works
describe('HOTEL-27752', () => { ... })"Issue does not exist or you do not have permission"
- Check the ticket exists in Jira
- Verify your JIRA_BASE_URL is correct
- Ensure your API token/PAT is valid
- Confirm you have permission to view the ticket
"Coverage shows too many files"
This should be fixed automatically! The tool filters coverage to only show the component being tested. If you see too many files, please report an issue.
Tests run but no coverage shown
Make sure your Jest config has coverage enabled:
{
"collectCoverageFrom": ["src/**/*.{ts,tsx}"]
}🏗️ Development
# Clone the repo
git clone https://github.com/ednaaaj/jira-test.git
cd jira-test
# Install dependencies
npm install
# Build
npm run build
# Link for local testing
npm link
# Now you can run
jira-test path/to/your/test.tsx🤝 Contributing
Contributions welcome! Please open an issue or PR.
📄 License
MIT
🙏 Credits
Built with ❤️ for developers who want automated test reporting in Jira without the overhead of expensive plugins.
