From e868a41fa1991fd229f319aee6c4d9709aaaede7 Mon Sep 17 00:00:00 2001 From: Grace Kind Date: Mon, 8 Dec 2025 10:09:38 -0500 Subject: [PATCH] Allow passing tests via CLI --- package.json | 2 +- runTests.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 60f0dd39..6964b89d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "bundle:capacitor": "esbuild ./clientLibs/capacitor.js --bundle --format=esm --outfile=src/js/lib/capacitor.js", "bundle:lit-html": "esbuild ./clientLibs/litHtml.js --bundle --format=esm --outfile=src/js/lib/lit-html.js", "test": "npm run test:unit", - "test:unit": "node --experimental-vm-modules node_modules/.bin/jest" + "test:unit": "node runTests.js" }, "license": "MIT", "devDependencies": { diff --git a/runTests.js b/runTests.js index b4756114..ec52d313 100644 --- a/runTests.js +++ b/runTests.js @@ -2,9 +2,17 @@ import fs from "fs"; import "./tests/env.js"; -// Get test files, pattern is **/*.test.js -// And may be in subdirectories -const testFiles = fs.globSync("tests/**/*.test.js"); +let testFiles = []; + +// If test files are provided as arguments, use them +// Otherwise, get test files from the tests directory +if (process.argv.length > 2) { + testFiles = process.argv.slice(2); +} else { + // Get test files, pattern is **/*.test.js + // And may be in subdirectories + testFiles = fs.globSync("tests/**/*.test.js"); +} const results = []; -- knotmirror 0.0.1