-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
What problem does this feature solve?
Hi team,
It would be great to have a JavaScript/TypeScript API for running rstest programmatically — e.g. from within scripts, CLIs, or dev tools — instead of having to shell out to a separate process.
Example use case
import { runTests } from 'rstest';
await runTests({
root: './my-project',
include: ['src/**/*.test.ts'],
watch: false,
reporters: ['dot'],
});Why this matters
- Enables integration into custom workflows
- Better scripting and automation support
- Makes it easier to build dev tools on top of rstest (e.g. wrappers, dashboards, IDE integrations)
Happy to discuss or contribute a design if this is something you’d be open to.
Thanks!
What does the proposed API look like?
Options
export interface RSTestOptions {
root?: string; // Project root directory
include?: string[]; // Glob patterns for test files
exclude?: string[]; // Glob patterns to exclude
watch?: boolean; // Watch mode
reporters?: string[]; // e.g. ['dot', 'json']
updateSnapshot?: boolean; // For snapshot testing
env?: NodeJS.ProcessEnv; // Custom env vars
// ... other rstest params
}Result type
export interface RSTestResult {
passed: number;
failed: number;
skipped: number;
duration: number;
exitCode: number;
errors?: string[];
}Signature
export async function runTests(options?: RSTestOptions): Promise<RSTestResult>;Example usage
import { runTests } from 'rstest';
const result = await runTests({
root: './',
include: ['src/**/*.test.ts'],
watch: false,
reporters: ['dot'],
});
console.log(`Tests finished: ${result.passed} passed, ${result.failed} failed.`);
process.exit(result.exitCode);9aoy, karlis-vagalis and chenjiahan
Metadata
Metadata
Assignees
Labels
No labels