@rpcbase/test 0.232.0 → 0.233.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/test",
3
- "version": "0.232.0",
3
+ "version": "0.233.0",
4
4
  "type": "module",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
package/src/cli.js CHANGED
@@ -17,7 +17,6 @@ const require = createRequire(import.meta.url)
17
17
  const moduleDir = path.dirname(fileURLToPath(import.meta.url))
18
18
 
19
19
 
20
- const TEST_GLOB = "{src,lib}/**/*.test.{js,ts,tsx}"
21
20
  const VITEST_COVERAGE_CANDIDATES = ["src/coverage.json"]
22
21
 
23
22
 
@@ -65,7 +64,12 @@ runTests()
65
64
  .catch(() => process.exit(1))
66
65
 
67
66
  async function runVitest(coverage) {
68
- const vitestArgs = ["run", TEST_GLOB, "--passWithNoTests"]
67
+ const vitestArgs = ["run", "--passWithNoTests"]
68
+ const vitestConfig = resolveVitestConfig()
69
+
70
+ if (vitestConfig) {
71
+ vitestArgs.push("--config", vitestConfig)
72
+ }
69
73
  const launcher = resolveVitestLauncher()
70
74
  const env = withRegisterShim(process.env)
71
75
 
@@ -200,6 +204,33 @@ function resolveVitestLauncher() {
200
204
  }
201
205
  }
202
206
 
207
+ function resolveVitestConfig() {
208
+ const userConfig = findVitestConfig(process.cwd())
209
+ if (userConfig) {
210
+ return userConfig
211
+ }
212
+
213
+ const bundledConfig = path.join(moduleDir, "vitest.config.mjs")
214
+ return fs.existsSync(bundledConfig) ? bundledConfig : null
215
+ }
216
+
217
+ function findVitestConfig(baseDir) {
218
+ const candidates = [
219
+ "vitest.config.ts",
220
+ "vitest.config.js",
221
+ "vitest.config.mjs",
222
+ ]
223
+
224
+ for (const file of candidates) {
225
+ const fullPath = path.join(baseDir, file)
226
+ if (fs.existsSync(fullPath)) {
227
+ return fullPath
228
+ }
229
+ }
230
+
231
+ return null
232
+ }
233
+
203
234
  async function loadVitestCoverageConfig() {
204
235
  const options = await loadCoverageOptions({
205
236
  optional: true,
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "vitest/config"
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ["{src,lib}/**/*.test.{js,ts,tsx}"],
6
+ },
7
+ })