koala73/worldmonitor · error · Error

Supply test files or globs

Error message

Supply test files or globs

What it means

scripts/run-data-tests.mjs is a CLI runner for data test files that supports sharding. After parsing the --shard INDEX/TOTAL option it validates that at least one test file or glob was passed as a positional argument; if none were, it throws 'Supply test files or globs'. It is a usage guard against invoking the runner with sharding options but no files to run.

Solutions

  1. Pass at least one test file or glob as a positional argument, e.g. `node scripts/run-data-tests.mjs 'tests/**/*.test.mjs'`
  2. Check the CI step or wrapper for an unexpanded/empty variable holding the file list
  3. Run `node scripts/run-data-tests.mjs --help` (or read the script header) to confirm expected usage

Example fix

// before
node scripts/run-data-tests.mjs --shard 1/2
// after
node scripts/run-data-tests.mjs --shard 1/2 'tests/data/**/*.test.mjs'
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2).filter(a => !a.startsWith('--'));
if (args.length === 0) {
  console.error('Usage: node scripts/run-data-tests.mjs [--shard N/T] <files...|globs...>');
  process.exit(2);
}

Type guard

const hasPositionals = (argv) => argv.some(a => !a.startsWith('--'));

Try / catch

try {
  await main();
} catch (err) {
  if (err.message === 'Supply test files or globs') {
    console.error('Usage: node scripts/run-data-tests.mjs [--shard N/T] <files|globs>');
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: Running `node scripts/run-data-tests.mjs` (optionally with --shard, --list, --concurrency, etc.) without any positional file or glob arguments, e.g. `node scripts/run-data-tests.mjs --shard 1/2`.

Common situations: CI workflow steps that build the file list in a variable which ends up empty (e.g. `node scripts/run-data-tests.mjs $FILES` with FILES=''); copy-pasting a documented command with the file list placeholder never filled; a wrapper script dropping positional args when forwarding flags.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15). Data as JSON: /api/errors/4165e0f4b8bedcfc. Report an issue: GitHub.

Appendix: source

Thrown at scripts/run-data-tests.mjs:53

      list: { type: 'boolean', default: false },
      timings: { type: 'string' },
      'test-name-pattern': { type: 'string' },
    },
  });
  if (!/^[1-9]\d*$/.test(values.concurrency) || !Number.isSafeInteger(Number(values.concurrency))) {
    throw new Error('Concurrency must be a positive integer');
  }
  let index = 1;
  let total = 1;
  if (values.shard) {
    const match = /^([1-9]\d*)\/([1-9]\d*)$/.exec(values.shard);
    if (!match) throw new Error('Shard must be INDEX/TOTAL (for example 1/2)');
    [index, total] = match.slice(1).map(Number);
    if (!Number.isSafeInteger(index) || !Number.isSafeInteger(total) || index > total) {
      throw new Error('Shard index must be between 1 and TOTAL');
    }
  }
  if (!positionals.length) throw new Error('Supply test files or globs');
  const files = [...new Set(positionals.flatMap((pattern) => {
    const matches = (existsSync(pattern) && statSync(pattern).isFile() ? [pattern] : globSync(pattern))
      .map((file) => file.split(sep).join('/'));
    if (!matches.length) throw new Error(`No test files match ${pattern}`);
    return matches;
  }))];
  const durations = JSON.parse(readFileSync(timingPath, 'utf8'));
  if (total > files.length) throw new Error('Shard count exceeds the test file count');
  const selected = partitionTests(files, durations, total)[index - 1];
  if (!selected.length) throw new Error('The selected shard contains no test files');
  if (values.list) {
    console.log(JSON.stringify(selected));
    return 0;
  }
  console.log(`Data tests: ${selected.length}/${files.length} files, shard ${index}/${total}, concurrency ${values.concurrency}`);
  const env = { ...process.env };
  // This is a new test run, even when a contract test invokes the CLI.
  delete env.NODE_TEST_CONTEXT;

View on GitHub (pinned to 7d06c8633d)