我正在尝试用笑话设置一个打字稿项目。然而,打字稿似乎没有从 中获取笑话类型@types/jest
,这突出显示了我的关键字,给了我以下错误:
Cannot find name 'test'. Do you need to install type definitions for a test runner? Try 'npm i @types/jest' or 'npm i @types/mocha'. ts(2582)
笔记:
{
"compilerOptions": {
"types": ["jest", "node"]
},
"types": ["jest"],
"typeRoots": ["./src/types", "./node_modules/@types"],
}
Run Code Online (Sandbox Code Playgroud)
module.exports = {
preset: 'ts-jest',
roots: ['<rootDir>/src'],
testEnvironment: 'node',
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};
Run Code Online (Sandbox Code Playgroud)
{
"presets": [
["@babel/preset-env", {"targets": {"node": "current"}}],
"@babel/preset-typescript"
],
"plugins": …
Run Code Online (Sandbox Code Playgroud)