slow-test-reporter
v1.0.0
Published
report slowest tests and provide suggestions
Maintainers
Readme
slow-test-reporter
A comprehensive Jest test reporter that identifies slow tests and provides actionable performance insights to optimize your test suite.
Features
- 📊 Detailed Performance Analysis - Identifies slowest tests with duration statistics
- 📈 Statistical Insights - Provides percentiles, median, standard deviation, and histograms
- 📁 File-level Analysis - Shows which test files consume the most time
- 🏗️ Suite Analysis - Identifies slow test suites and describe blocks
- 💡 Smart Recommendations - Suggests specific optimizations based on your test patterns
- 🎨 Colorized Output - Easy-to-read colored terminal output
- 📋 Multiple Output Formats - Human-readable text or JSON for automation
- ⚡ Overhead Detection - Identifies files with high setup/teardown overhead
Installation
bun:
bun add -d slow-test-reporternpm:
npm install --save-dev slow-test-reporterpnpm:
pnpm add -D slow-test-reporteryarn:
yarn add --dev slow-test-reporterUsage
Basic Configuration
Add the reporter to your Jest configuration:
// jest.config.js
module.exports = {
reporters: [
'default',
'slow-test-reporter'
]
};With Options
// jest.config.js
module.exports = {
reporters: [
'default',
'slow-test-reporter'
]
};Output Example
Top 30 slowest examples (8.4 s, 18.6% of total time):
Database migration rollback test
2.85 s ./src/database/migrations.test.js
Large file upload with validation
2.12 s ./src/uploads/fileProcessor.test.js
Complex authentication flow
1.94 s ./src/auth/integration.test.js
Average test time: 36.24 ms
Median test time: 18.00 ms
Standard deviation: 127.45 ms
Slowest test is 78.6x slower than average
Percentiles:
90th: 128.00 ms
95th: 267.00 ms
99th: 891.00 ms
Tests exceeding threshold (>300 ms): 15
Duration histogram:
0-50ms: 1089 ████████████████████████████████████████████████
51-100ms: 98 ████
101-200ms: 45 ██
201-500ms: 12 ▌
501-1000ms: 2 ▌
1000ms+: 1 ▌
Top 5 slowest files (by total test duration):
./src/database/migrations.test.js: 6.24 s (15 tests, avg: 416.00 ms), overhead: 1.2 s (19.2%)
./src/uploads/fileProcessor.test.js: 4.81 s (23 tests, avg: 209.13 ms), overhead: 0.8 s (16.6%)
./src/auth/integration.test.js: 3.94 s (8 tests, avg: 492.50 ms), overhead: 0.3 s (7.6%)
Top 5 slowest test suites:
Database Integration Tests: 8.34 s (28 tests, avg: 297.86 ms)
File Upload Processing: 6.12 s (31 tests, avg: 197.42 ms)
Authentication Flows: 4.88 s (19 tests, avg: 256.84 ms)
Recommended Improvements:
- 3 file(s) spend >50% of their runtime in setup/teardown. Potential impact: 2.3 s saved if optimized.
- 2 file(s) are in the top 10% for both test count and total time. Consider splitting/refactoring.
- 5 test(s) are >10x slower than the median. Investigate for unnecessary waits or unmocked dependencies.
## Requirements
- Node.js ≥ 20.0.0
- Jest ≥ 27.0.0
## License
MIT © Doug Schlenker
## Contributing
Issues and pull requests are welcome! Please see the [GitHub repository](https://github.com/schlenks/slow-test-reporter) for more information.