Mocha Reporter
Send your Mocha test results directly to your TestPig.io dashboard with our dedicated Mocha reporter.
Mocha + TestPig.io = Elegant test reporting!
Quick Installation ⚡
npm install @testpig/mocha-reporter --save-dev
Configuration 🛠️
Step 1: Add the Reporter to Your Configuration File (Required)
First, add the TestPig.io reporter to your Mocha configuration. This can be done in several ways:
In your .mocharc.js
file:
// .mocharc.js
module.exports = {
reporter: '@testpig/mocha-reporter'
}
In your .mocharc.json
file:
// .mocharc.json
{
"reporter": "@testpig/mocha-reporter"
}
Or via command line:
mocha --reporter @testpig/mocha-reporter
Step 2: Point Reporter to TestPig
Method 1: Environment Variables (Recommended 👍)
Set these environment variables for maximum flexibility:
export TESTPIG_PROJECT_ID=your-project-id
export TESTPIG_RUN_ID=your-run-id # Optional
export TESTPIG_API_KEY=your-api-key
Your Mocha config remains clean with just the reporter definition as shown above.
Method 2: Configuration File Options
Alternatively, specify credentials directly in your configuration:
In your .mocharc.js
file:
// .mocharc.js
module.exports = {
reporter: '@testpig/mocha-reporter',
reporterOptions: {
projectId: 'your-project-id',
runId: 'your-run-id', // Optional
apiKey: 'your-api-key'
}
}
In your .mocharc.json
file:
// .mocharc.json
{
"reporter": "@testpig/mocha-reporter",
"reporter-option": [
"projectId=your-project-id",
"runId=your-run-id",
"apiKey=your-api-key"
]
}
Or via command line:
mocha --reporter @testpig/mocha-reporter --reporter-options projectId=your-project-id,runId=your-run-id,apiKey=your-api-key
Using It Is a Breeze 🌬️
Run your Mocha tests as usual:
npx mocha
That's it! Your results will magically appear in your TestPig.io dashboard.
Awesome Features You'll Love ❤️
- Complete Suite Reporting: Every aspect of your test suites beautifully organized
- Detailed Error Information: Pinpoint exactly what went wrong and where
- Performance Tracking: Monitor test durations for optimization
- Custom Metadata Support: Add your own context to test runs
- Automatic Test Hierarchy: Intuitive organization of your test structure
Configuration Options At-a-Glance 📋
Option | What It Does | Required? |
---|---|---|
projectId | Links results to your TestPig.io project | ✅ Yes |
runId | Groups tests under a single run identifier | ❌ No |
apiKey | Your secure access key to TestPig.io | ✅ Yes |
Check our Best Practices guide for advanced configuration strategies.
Getting Help
If you encounter issues with the Mocha reporter:
- Check the Mocha Reporter GitHub repository for reporter-specific code issues
- Visit support.testpig.io for all bugs, feature requests, account or technical issues