Reputation: 2601
I've started a new Typescript project with GTS. The typings are working fine for regular *.ts files but nothing I've tried works to get *.spec.ts files to work.
Every jest function is marked red by ESLint in VS code. The message will say "(describe | it | expect) is not defined". I have tried including and excluding files, adding types, and copying from other projects.
Here 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 root directory is simple
Relevant 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 something obvious I have done wrong in my config? Should I have 2 configs, one for ts, the other for spec?
Upvotes: 1
Views: 1622
Reputation: 2601
The problem was ESLint configuration. I added this to the .eslintrc.json
file and the errors went away:
"env": {
"browser": true,
"es6": true,
"jest": true,
"node": true
},
Upvotes: 3