docmirror/dev-sidecar · error

Tests directory not found: ${resolvedDir}

Error message

Tests directory not found: ${resolvedDir}

What it means

`loadAllTests` in the free-eye plugin resolves the tests directory via `resolveTestsDir(testsDir)` and throws if that directory does not exist on disk. It refuses to continue rather than silently returning zero tests. The resolved path is included in the message so you can see exactly what was looked for.

Source

Thrown at packages/core/src/modules/plugin/free-eye/client.js:55

const pluginRequire = createRequire(path.join(PLUGIN_ROOT, 'index.js'))

function resolveTestsDir (customDir) {
  const fallbackDir = path.join(PLUGIN_ROOT, TEST_PACKAGE_DIR)
  if (!customDir) {
    return fallbackDir
  }
  if (path.isAbsolute(customDir)) {
    return fs.existsSync(customDir) ? customDir : fallbackDir
  }
  const candidate = path.join(PLUGIN_ROOT, customDir)
  return fs.existsSync(candidate) ? candidate : fallbackDir
}

async function loadAllTests (testsDir, globalConfig) {
  const tests = []
  const resolvedDir = resolveTestsDir(testsDir)
  if (!fs.existsSync(resolvedDir)) {
    throw new Error(`Tests directory not found: ${resolvedDir}`)
  }
  const files = fs.readdirSync(resolvedDir).filter(file => file.endsWith('.js') && file !== '__init__.js')

  for (const file of files) {
    const modulePath = path.join(resolvedDir, file)

    const module = pluginRequire(modulePath)
    const getClientTests = module.getClientTests || (module.default && module.default.getClientTests)
    if (typeof getClientTests === 'function') {
      for (const testCls of getClientTests()) {
        if (testCls.getTestTag() in globalConfig) {
          tests.push(testCls)
        }
      }
    }
  }
  return tests
}

View on GitHub (pinned to 7710cd56cc)

Solutions

  1. Verify the resolved path printed in the error exists (`ls <resolvedDir>`) and fix `testsDir` accordingly.
  2. Pass an absolute path for `testsDir` so it does not depend on process.cwd().
  3. If running the packaged app, ensure the tests directory is bundled with the application assets.
  4. Create the directory with at least one `.js` test file if it is meant to be populated at runtime.

Example fix

// before
await runTests({ testsDir: 'tests/free-eye' })
// after
const path = require('path')
await runTests({ testsDir: path.join(__dirname, 'tests/free-eye') })
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
const path = require('path')
const resolvedDir = path.isAbsolute(testsDir) ? testsDir : path.resolve(process.cwd(), testsDir)
if (!fs.existsSync(resolvedDir)) {
  throw new Error(`Fix testsDir before calling runTests: ${resolvedDir} missing`)
}

Type guard

function hasTestsDir (testsDir) {
  return typeof testsDir === 'string' && testsDir.length > 0 && fs.existsSync(testsDir)
}

Try / catch

try {
  await runTests({ testsDir, config })
} catch (err) {
  if (err.message.startsWith('Tests directory not found')) {
    console.error('Point testsDir at an existing directory:', err.message)
  } else { throw err }
}

Prevention

When it happens

Trigger: Calling `runTests({ testsDir })` (via `todoTests`) where `resolveTestsDir` produces a path that does not exist — e.g. an absolute `testsDir` that was never created, a wrong relative path, or the free-eye test assets missing from a packaged install.

Common situations: Passing a testsDir relative to the wrong working directory; renaming/moving the tests folder; packaged binaries where the tests directory is not bundled; typos in a config file pointing at the tests dir.

Related errors


AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31). Data as JSON: /api/errors/c3958e902f3b7602. Report an issue: GitHub.