Skip to content

Commit 20b4450

Browse files
committed
refactor: merge test-changed.mjs into test.mjs
- Unified test runner with all functionality in test.mjs - Added support for positional arguments to pass through to vitest - Removed redundant test-changed.mjs file - Updated sync-scripts.mjs to reflect the merge - Enhanced help text to show vitest argument passthrough capability
1 parent d0dabde commit 20b4450

File tree

3 files changed

+11
-160
lines changed

3 files changed

+11
-160
lines changed

scripts/sync-scripts.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const SOCKET_PROJECTS = [
2020

2121
const FILES_TO_SYNC = [
2222
'scripts/test.mjs',
23-
'scripts/test-changed.mjs',
2423
'scripts/lint.mjs',
2524
'scripts/build.mjs',
2625
'scripts/clean.mjs',

scripts/test-changed.mjs

Lines changed: 0 additions & 154 deletions
This file was deleted.

scripts/test.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async function runBuild() {
112112
return 0
113113
}
114114

115-
async function runTests(options) {
115+
async function runTests(options, positionals = []) {
116116
const { all, coverage, force, staged, update } = options
117117
const runAll = all || force
118118

@@ -152,6 +152,11 @@ async function runTests(options) {
152152
vitestArgs.push(...testsToRun)
153153
}
154154

155+
// Add any additional positional arguments
156+
if (positionals.length > 0) {
157+
vitestArgs.push(...positionals)
158+
}
159+
155160
const spawnOptions = {
156161
cwd: rootPath,
157162
env: {
@@ -180,7 +185,7 @@ async function runTests(options) {
180185
async function main() {
181186
try {
182187
// Parse arguments
183-
const { values } = parseArgs({
188+
const { positionals, values } = parseArgs({
184189
options: {
185190
help: {
186191
type: 'boolean',
@@ -223,14 +228,14 @@ async function main() {
223228
default: false,
224229
},
225230
},
226-
allowPositionals: false,
231+
allowPositionals: true,
227232
strict: false,
228233
})
229234

230235
// Show help if requested
231236
if (values.help) {
232237
printHelpHeader('Test Runner')
233-
console.log('\nUsage: pnpm test [options]')
238+
console.log('\nUsage: pnpm test [options] [-- vitest-args...]')
234239
console.log('\nOptions:')
235240
console.log(' --help Show this help message')
236241
console.log(' --fast, --quick Skip lint/type checks for faster execution')
@@ -245,6 +250,7 @@ async function main() {
245250
console.log(' pnpm test --cover # Run with coverage report')
246251
console.log(' pnpm test --fast --cover # Quick test with coverage')
247252
console.log(' pnpm test --update # Update test snapshots')
253+
console.log(' pnpm test -- --reporter=dot # Pass args to vitest')
248254
process.exitCode = 0
249255
return
250256
}
@@ -279,7 +285,7 @@ async function main() {
279285
}
280286

281287
// Run tests
282-
exitCode = await runTests({ ...values, coverage: withCoverage })
288+
exitCode = await runTests({ ...values, coverage: withCoverage }, positionals)
283289

284290
if (exitCode !== 0) {
285291
log.error('Tests failed')

0 commit comments

Comments
 (0)