test-metrics-analyzer
v1.0.20
Published
CLI tool to generate and view metrics from Playwright test suites
Maintainers
Readme
test-metrics-analyzer
A CLI tool to analyze Playwright
.spec.tstest files and generate test metrics — including total tests, steps, and cases. Also includes a live dashboard viewer.
Features
- Analyze a single spec file or a full test directory
- Count total
test()andtest.step()calls - Recursively resolves and analyzes imports
- Excludes files like
examples.spec.tsby default - Outputs structured metrics as JSON
- Optional live HTML dashboard viewer (
servemode)
Installation
Use it directly without installing:
npx test-metrics-analyzerOr install globally:
npm install -g test-metrics-analyzerUsage
Analyze an entire test folder
npx test-metrics-analyzer testsAnalyzes all .spec.ts files (excluding examples.spec.ts) under the tests directory.
Analyze a single spec file
npx test-metrics-analyzer tests/auth/login.spec.tsAnalyzes only the provided file (with import tracing).
Start the metrics dashboard server
npx test-metrics-analyzer serveStarts a local Express server at:
http://localhost:3000
The server loads metrics from the previously generated test-metrics-analyzer/test-metrics.json file.
Output
A new folder will be created:
test-metrics-analyzer/
└── test-metrics.jsonExample test-metrics.json:
{
"auth/login": {
"totalTests": 3,
"totalTestSteps": 5,
"totalTestCases": 5
},
"dashboard/home": {
"totalTests": 4,
"totalTestSteps": 8,
"totalTestCases": 8
},
"_total": {
"totalTests": 7,
"totalTestSteps": 13,
"totalTestCases": 13
}
}CLI Options
| Command / Argument | Description |
|--------------------|------------------------------------------|
| [path] | Directory or file path to analyze |
| serve | Launches a local dashboard server |
| (none) | Defaults to analyzing ./tests folder |
License
MIT
Author
Morpheus
GitHub: [https://github.com/DevMorph77]
