chore(test): add filter wrapper for vitest
This commit is contained in:
parent
d0cdf3a0c5
commit
e9dfbe134f
@ -32,7 +32,7 @@
|
||||
"typecheck": "tsgo --project tsconfig.json --noEmit",
|
||||
"test": "cross-env MCPORTER_TEST_REPORTER=quiet pnpm test:verbose",
|
||||
"test:quiet": "cross-env MCPORTER_TEST_REPORTER=quiet pnpm test:verbose",
|
||||
"test:verbose": "vitest run",
|
||||
"test:verbose": "node scripts/test-runner.js",
|
||||
"test:live": "MCP_LIVE_TESTS=1 vitest run tests/live",
|
||||
"clean": "rimraf dist",
|
||||
"dev": "tsc -w -p tsconfig.build.json",
|
||||
|
||||
34
scripts/test-runner.js
Normal file
34
scripts/test-runner.js
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env node
|
||||
// Lightweight wrapper to translate `--filter foo` into Vitest include globs so
|
||||
// callers can run `pnpm test --filter my-test` without hitting the Vitest CLI
|
||||
// "Unknown option --filter" error.
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const translated = [];
|
||||
const positional = [];
|
||||
|
||||
for (let i = 0; i < args.length; i += 1) {
|
||||
const token = args[i];
|
||||
if (token === '--filter' || token === '-f') {
|
||||
const pattern = args[i + 1];
|
||||
if (!pattern) {
|
||||
console.error('[test-runner] --filter requires a pattern');
|
||||
process.exit(1);
|
||||
}
|
||||
positional.push(pattern);
|
||||
i += 1; // skip pattern
|
||||
continue;
|
||||
}
|
||||
translated.push(token);
|
||||
}
|
||||
|
||||
const bin = path.join(process.cwd(), 'node_modules', '.bin', 'vitest');
|
||||
const result = spawnSync(bin, ['run', ...positional, ...translated], {
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
Loading…
Reference in New Issue
Block a user