jest-test-list v0.1.0
jest-test-list
jest-test-list is a powerful and flexible CLI tool for listing Jest tests in your project. With support for customizable output formats, clipboard integration, and Jest CLI options, it provides a streamlined way to inspect and manage your test suite.
Features
CLI
- Output Formats: Display test lists as
inlineor in atreestructure. - Color Control: Enable or disable colored output.
- Clipboard Integration: Copy test lists directly to your clipboard.
- Customizable Package Management: Specify a package manager or allow auto-detection.
- Working Directory Flexibility: Run Jest commands from any directory.
- Extended Jest Options: Pass any valid Jest CLI options.
API
- Use the API method
extractTreeto programmatically access test lists.
Installation
Install jest-test-list globally using npm or yarn:
npx jest-test-list
bunx jest-test-list
pnpm exec jest-test-listor
Usage
npx jest-test-list <flags> <jest-options>Options
| Option | Alias | Description | Default |
|---|---|---|---|
--format | -f | Output format: inline or tree | tree |
--noColor | Disable color output | false | |
--copyToClipboard | -c | Copy the output to the clipboard | false |
--packageManager | -p | Specify package manager to use (e.g., npm, yarn) | auto |
--workingDir | -w | Set working directory to run Jest in | Current directory |
--maxBuffer | Set max buffer size for child process | 1024 * 1024 bytes | |
-- <jest-options> | Any valid Jest CLI options | - |
Examples
Basic Usage
List all tests in the default format:
npx jest-test-listDisable Color Output
Run without color formatting:
npx jest-test-list --noColor -- <jest-options>Specify Jest Options
Pass specific Jest CLI options:
npx jest-test-list -- --runInBand -- MyTestFile.test.tsCopy to Clipboard
Copy test results directly to the clipboard:
npx jest-test-list --copyToClipboardChange Output Format
List tests in an inline format:
npx jest-test-list --format inlineAPI Usage
The jest-test-list package provides an API method for programmatic usage:
extractTree
interface ExtractTreeOptions {
packageManager?: string;
maxBuffer?: number;
extras?: string;
cwd?: string;
}
export async function extractTree(options: ExtractTreeOptions = {}): Promise<TestsByFile[]>;Parameters
packageManager(optional): Specify the package manager to use (e.g.,npm,yarn).maxBuffer(optional): Set the maximum buffer size for the child process.extras(optional): Additional CLI arguments to pass.cwd(optional): Specify the current working directory for the Jest process.
Returns
A promise that resolves to an array of TestsByFile objects, representing the extracted test structure.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push to your branch.
- Submit a pull request with a detailed description of your changes.
License
This project is licensed under the MIT License.
Feedback & Support
For issues, feature requests, or general questions, please open an issue in the GitHub repository.