targeted-test-runner
v1.0.30
Published
CLI tool for running targeted tests by description
Downloads
119
Readme
Targeted Test Runner (tt)
A CLI tool for running specific tests by description without manually modifying test files.
Installation
npm install targeted-test-runner -gUsage
tt --help
Basic Usage
Run all test files in the current directory:
ttRun a specific test by its description:
tt "should handle user login"The tool will:
- Find all test files in the current directory
- Fuzzy match the test description (if provided)
- Create a temporary file with
.onlyadded to the matched test (if description provided) - Run the test(s)
- Clean up any temporary files
Examples
# Run all tests in the current directory
tt
# List all available tests
tt --list
# Run a specific test by description
tt "should handle user login"
# Run all tests matching a description
tt "login" --all
# Run all tests in a specific file
tt src/tests/auth.test.js
# Run tests in a specific file matching a description
tt src/tests/auth.test.js "login"
# Run all tests in a directory
tt src/tests/
# Run tests in a directory matching a description
tt src/tests/ "login"Advanced Usage
Run Tests from a Specific File
Run tests from a specific file by providing the file path first:
tt ./path/to/test.js "test description"Run All Matching Tests
Use the -a or --all flag to run all matching tests instead of just the best match:
# Run all tests matching the description
tt "test description" -a
# Run all tests from a specific file matching the description
tt ./path/to/test.js "test description" -a Example
Given a test file test-file.test.js
// test-file.test.js
const { test } = require('uvu')
const assert = require('uvu/assert')
test('test one', () => {
assert.equal(1, 1)
})
test('test two', () => {
assert.equal(2, 2)
})
test.run()You can target specific tests:
tt test-file.test.js "two"This will automagically create a temp file with test.only applied to our matches:
// test-file.test.js
const { test } = require('uvu')
const assert = require('uvu/assert')
test('test one', () => {
assert.equal(1, 1)
})
test.only('test two', () => {
assert.equal(2, 2)
})
test.run()Run specific tests:
# Run all test files in the directory
tt
# Run the best matching test with description matching "foo"
tt 'foo'
# Run all tests containing 'api requests'
tt 'api requests' --all
# Run tests only from a specific file
tt ./path/to/test.js 'test description xyz'
# Run all tests in a dir
tt ./path/to/dir
# Run tests only from a dir that match `xyz`
tt ./path/to/dir 'xyz'
# Run all matching tests from a specific file
tt ./path/to/test.js 'test' --allConfiguration
Debug Logging
Enable debug logging by setting the DEBUG environment variable:
DEBUG=tt:* tt 'test description'Available debug namespaces:
tt:cli: CLI operationstt:processor: Test file processingtt:runner: Test execution
Development
Setup
npm installRunning Tests
npm testProject Structure
.
├── src/
│ ├── index.js # CLI entry point
│ └── utils/
│ ├── logger.js # Logging configuration
│ ├── test-processor.js # Test file processing
│ ├── test-runner.js # Test execution
│ └── cleanup.js # Temporary file cleanup
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
└── fixtures/ # Test fixturesLicense
ISC
