test-exclude is a JavaScript library designed to apply include and exclude glob patterns to file paths, primarily utilized within the istanbuljs ecosystem for test coverage tools like nyc and babel-plugin-istanbul. The current stable version is 8.0.0. Its release cadence is driven by updates to underlying dependencies like glob and minimatch, and by Node.js version support, typically seeing a few major versions per year. Key differentiators include its tight integration with istanbuljs tooling, robust handling of common exclusion patterns such as node_modules by default, and support for configurable file extensions. It offers both synchronous (globSync) and asynchronous (glob) methods for retrieving lists of files that match the defined inclusion/exclusion rules, making it versatile for various build and testing workflows.
npm install test-excludeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize TestExclude, use `shouldInstrument` for individual files, and `glob` to find all matching files within a CWD.
Ensure your project's Node.js environment is version 20 or greater. Update your `package.json` engines field to reflect this requirement and upgrade Node.js if necessary.
If migrating from a version prior to 7.0.0, upgrade your Node.js environment to version 18 or greater.
Pass `{ excludeNodeModules: false }` to the `TestExclude` constructor if you intend to instrument files within `node_modules`.Always ensure your `TestExclude` instance is initialized with a `cwd` that encompasses all relevant files you intend to process. For `glob` and `globSync`, the `cwd` argument can only further restrict results within `options.cwd`.
Ensure all relevant file extensions are listed in `options.extension`. If using TypeScript or JSX, verify your build or coverage tooling has the necessary Babel/TypeScript plugins configured.
Upgrade your Node.js environment to version 20 or newer. Check your CI/CD pipelines and local development setups.
Inspect `options.excludeNodeModules` and `options.exclude` when initializing `TestExclude`. You may need to set `excludeNodeModules: false` or override specific patterns in your `exclude` array. Also, verify `options.extension`.
Verify the `cwd` is correct and encompasses your project. Review `options.include`, `options.exclude`, and `options.extension`. Ensure the `cwd` argument to `glob` is not stricter than the constructor's `options.cwd`.