For AI agents: the complete documentation index is available at https://rstest.rs/llms.txt, the full documentation bundle is available at https://rstest.rs/llms-full.txt, and this page is available as Markdown at https://rstest.rs/config/test/include.md.
close
  • English
  • include

    • Type: string[]
    • Default: ['**/*.{test,spec}.?(c|m)[jt]s?(x)']
    • CLI: --include '**/*.test.ts' --include '**/*.spec.ts'

    Glob patterns that match test files, resolved relative to root (process.cwd() by default). Setting include replaces the default patterns.

    CLI
    rstest.config.ts
    npx rstest --include '**/*.{test,spec}.?(c|m)[jt]s?(x)'

    Run npx rstest list --filesOnly to inspect the matched test files:

    $ npx rstest list --filesOnly
    
    a.test.ts
    b.test.ts

    Default behavior

    By default, Rstest matches JavaScript and TypeScript files whose filenames contain .test. or .spec.:

    ├── __tests__
    │   └── index.test.js # test
    │   └── App.spec.tsx # test
    │   └── helper.ts # not test
    ├── src
    │   └── component.ts # not test
    │   └── component.test.tsx # test
    ├── bar.spec.jsx # test
    ├── index.test.js # test
    └── index.js # not test

    Patterns without a directory prefix (such as index.test.ts) match only in the root directory. Use **/index.test.ts to match subdirectories:

    import { defineConfig } from '@rstest/core';
    
    export default defineConfig({
    -  include: ['index.test.ts'],
    +  include: ['**/index.test.ts'],
    });

    For a single extension, write **/*.ts instead of **/*.{ts}. Single-value braces are matched literally, so **/*.{ts} does not match .ts files.