I have been trying to run some tests located in its own folder using Jest but it claims that no tests have been found.
The file structure is as follows:
.
└── repo-folder/
    ├── ...
    └── tests/
        ├── integration/
        │   └── ...
        └── unit/
            ├── 1.test.ts
            ├── 2.test.ts
            ├── ...
            └── 4.test.ts
What I want to do is to run the unit tests without running the integration tests. To do this I have tried using the Jest CLI command (from package.json):
jest --roots=./tests/unit
However, this results in the following error:
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /home/myusername/repos/repo-folder
  4 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 4 matches
  testPathIgnorePatterns: build - 0 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches
I have tried a few different flags for Jest such as --testPathPattern or just adding the file path as an argument at the end of the command, though this actually found all test files in the root directory. I found a similar previous question Jest No Tests found but in my own Jest config only the build directory for the TypeScript build is ignored.
The project uses ts-jest and jest-extended if that may somehow cause any issues for Jest. My jest.config.js looks like this:
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
    clearMocks: true,
    moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
    roots: ['<rootDir>'],
    transform: {
        '^.+\\.ts?$': 'ts-jest',
    },
    setupFilesAfterEnv: ['jest-extended'],
    globals: {
        'ts-jest': {
            diagnostics: false,
            isolatedModules: true,
        },
    },
    preset: 'ts-jest',
    testEnvironment: 'node',
    coverageProvider: 'v8',
    testPathIgnorePatterns: ['build'],
};