Skip to the content.

Common Issues & Solutions

Table of Contents

Discovery Lens for fast feedback

When discovery surprises you (wrong top hit, no candidates, confusing scores), use the Discovery Lens CLI to see exactly why:

npx adaptive-tests why '{"name":"YourClass"}'
npx adaptive-tests why '{"name":"YourClass"}' --json  # structured output for CI/tools

The output shows ranked candidates with per‑factor contributions (path, fileName, typeHints, methods, exports, nameMentions, custom, recency). Adjust adaptive-tests.config.js and rerun why to confirm improvements.

1. Discovery skipped my module

Symptoms: createDiscoveryError mentions candidates but says “none matched all requirements”.

Fix (Signature tuning)

  1. Start with the simplest signature – just the name.
  2. Add type, then methods/properties only if you truly need them.
  3. Remember that names are case-insensitive and AST-driven exports require real methods on the prototype (class) or object.
  4. Check the scoring configuration (see adaptive-tests.config.js) if your file lives in an unusual directory. You can temporarily boost a path to confirm the engine sees it.
await engine.discoverTarget({ name: 'UserService' });
// If that fails, you probably have a naming mismatch or the file isn’t exported.

2. AST parse failures

Symptoms: The engine logs “Failed to parse candidate” internally and skips a file; discovery ultimately fails.

Fix (Parser failures)

3. I moved a file and still get the old implementation

We default to mtime-based cache invalidation, but if your editor copies the file without updating the timestamp, force a clear:

await engine.clearCache();           // wipe discovery + runtime cache

Need extra diagnostics? Set discovery.cache.logWarnings to true in your config to surface read/write issues with the persistent cache (mirrored in the Python engine as log_warnings). Default cache entries now expire after 24 hours; adjust discovery.cache.ttl (or ttl_seconds in Python) if your workflows require longer persistence.

You should rarely need to touch require.cache manually now that the engine tracks modification times and recompiles changed modules.

4. Multiple exports in one module

You can discover each export independently; the AST metadata allows the engine to resolve named exports safely.

const { discover } = require('adaptive-tests');

const processArray = await discover({ name: 'processArray', type: 'function' });
const transformData = await discover({ name: 'transformData', type: 'function' });

5. Test files or fixtures getting picked as candidates

The default scoring and skip lists exclude common test directories. If you have a fixture that should never be considered, add an explicit negative path score in adaptive-tests.config.js:

module.exports = {
  discovery: {
    scoring: {
      paths: {
        negative: {
          '/my-fixtures/': -100
        }
      }
    }
  }
};

6. Discovering by inheritance or properties still fails

The AST metadata detects extends and prototype assignments, but it cannot instantiate classes that require constructor arguments. If your constructor needs parameters or performs side effects, prefer method/property signatures rather than strict inheritance checks.

await engine.discoverTarget({
  type: 'class',
  properties: ['sessions'],
  methods: ['login', 'logout']
});

Debug Checklist

If you are still stuck, open an issue with:

We are happy to help!