Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  1] [ 1]  / answers: 1 / hits: 18152  / 5 Years ago, sat, october 19, 2019, 12:00:00

Is it possible to exclude all test files only for the build but use them with nodemon to run tests locally? When I exclude test files within the tsconfig.json file I get a typescript error that it can't find the types of the testing library like jest in my case.



Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.ts(2582)



{
compilerOptions: {},
exclude: [
**/*.test.ts
]
}


I am wondering since I guess the temporary transpiling is put into another folder than the build folder.


More From » typescript

 Answers
31

One possible solution would be to use two different tsconfig files, one for the tests and one for the production build.


tsconfig.json


{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "./build",
"baseUrl": ".",
"paths": {
"*": ["types/*"]
},
"strict": true,
}
}

tsconfig.prod.json


{
"extends": "./tsconfig",
"exclude": ["**/*.test.ts", "**/*.mock.ts"]
}

Then point tsc to the new config when running tsc -p tsconfig.prod.json


[#51556] Thursday, October 10, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alejandro

Total Points: 231
Total Questions: 102
Total Answers: 107

Location: Jordan
Member since Wed, Jun 17, 2020
4 Years ago
alejandro questions
Mon, Jul 18, 22, 00:00, 2 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Thu, Sep 10, 20, 00:00, 4 Years ago
;