Recently, I began a new Typescript project utilizing GTS. While the typings are functioning correctly for regular *.ts files, I am encountering difficulties in getting *.spec.ts files to work.
Issue
Each jest function is being flagged as red by ESLint within VS Code with the message stating "(describe | it | expect) is not defined". Despite my attempts of including and excluding files, adding types, and even copying from other projects, the problem persists.
Below is my current tsconfig:
{
"compileOnSave": false,
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"sourceMap": true,
"declaration": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"types": ["node", "jest"]
},
"exclude": ["**/*.spec.ts"],
"include": ["src/**/*.ts", "tests/**/*.ts"]
}
The directory structure is quite straightforward
- src (containing ts files)
- tests (housing all spec files)
- tsconfig.json
Key Packages:
"@types/jest": "^26.0.14",
"@types/node": "^13.11.1",
"gts": "^2.0.2",
"jest": "^26.4.2",
"tslint": "^6.1.3",
"typescript": "^4.0.3"
Is there a glaring mistake in my configuration? Should I create two separate configs, one for ts files, and the other for spec files?