Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problem in the tsconfig.json file when trying to use Jest with Typescript

The error message I am getting is:

File 'd:/Project/server/jest.config.ts' is not under 'rootDir' 
'd:/Project/server/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Matched by include pattern '**/*' in 'd:/Project/server/tsconfig.json'

My tsconfig.json file is:

{
 "compilerOptions": {
    "target": "es2020",
    "module": "commonjs",

    "rootDir": "./src",
    "outDir": "./dist",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

My jest.config.ts file is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

export default {
    clearMocks: true,
    collectCoverage: true,
    coverageDirectory: "coverage",
    coverageProvider: "v8",
    transform: {
        "^.+\\.(t|j)sx?$": ["@swc/jest"],
    },
};

I am trying to exactly follow the directives of each documentation.

What am I doing wrong here?

>Solution :

You have to move your jest.config.ts file inside your src/ directory in order to work. The error is self explanatory I would say.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading