typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

--exclude option not working with test files

Open lianulloa opened this issue 4 months ago • 1 comments

Search terms

exclude option test describe expect

Expected Behavior

Typedoc ignores tests files

Actual Behavior

Typedoc throws errors related to test files that should be ignore

Steps to reproduce the bug

I am experiencing this issue now

I am trying to run typedoc like this: npx typedoc --entryPointStrategy Expand --exclude "**/*+(.spec|.test).ts" src/lib

I got the pattern from the docs

// tsconfig.json
{
  //...
  "exclude": ["node_modules", "**/*.test.{tsx,ts}", "src/test",]
}

Running the command gives error output like

src/lib/styling.test.ts:5:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.

 describe("getHslColor", () => {
  ~~~~~~~~

I have also tried by running this script inspire by the docs

import * as td from "typedoc";

async function main() {

  // Application.bootstrap also exists, which will not load plugins
  // Also accepts an array of option readers if you want to disable
  // TypeDoc's tsconfig.json/package.json/typedoc.json option readers
  const app = await td.Application.bootstrapWithPlugins({
      // Note: This accepts globs, do not pass paths with backslash path separators!
      entryPoints: ["src/lib/"],
      entryPointStrategy: "Expand",
      exclude: [ "**/*.test.ts", "**/*+(.spec|.test).ts"],
      tsconfig: "tsconfig.json",
      // Other options here
  });
  
  // May be undefined if errors are encountered.
  const project = await app.convert();
  
  if (project) {
      // Generate configured outputs
      await app.generateOutputs(project);
  
      // Alternatively...
      const outputDir = "docs";
      // Generate HTML rendered docs
      await app.generateDocs(project, outputDir);
      // Alternatively generate JSON output
      await app.generateJson(project, outputDir + "/docs.json");
  }
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Environment

  • TypeDoc version: ^0.28.14
  • TypeScript version: ^5.9.3
  • Node.js version: 22.21.1
  • OS: macOS

lianulloa avatar Nov 20 '25 10:11 lianulloa

I suggest reading the description for this option. https://typedoc.org/documents/Options.Input.html#exclude

Gerrit0 avatar Nov 20 '25 12:11 Gerrit0