【发布时间】:2022-01-01 07:57:26
【问题描述】:
我正在尝试在我的项目中配置赛普拉斯。我遇到了 Cypress 的 typescript 配置问题,需要您的帮助! 这是我的项目的样子:
fronend/
- cypress/
-tsconfig.json
- src/
- tsconfig.json
- package.json
- cypreess.json
这是我来自 Cypress 目录的 tsconfig.json:
{
"extends": "../tsconfig.json",
"include": ["./**/*.ts"],
"exclude": [],
"compilerOptions": {
"types": ["cypress"],
"lib": ["es2015", "dom"],
"isolatedModules": false,
"composite": true
}
}
这是我前端目录中的 tsconfig.json 文件:
{
"compilerOptions": {
"baseUrl": "src",
"rootDir": "src",
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.svg"],
"exclude": ["node_modules", "scripts"],
"references": [
{
"path": "./cypress/"
}
]
}
没有"extends": "../tsconfig.json",Cypress 也可以正常工作,但我需要它,因为我想在 cypress ts 文件中从 src 目录导出文件。
您能告诉我我的配置有什么问题吗? 我宁愿不要更改主 tsconfig.json 文件,因为它运行我们的 UI。 这是我的错误:
File '/**/fronend/cypress/support/objects/client.ts' is not under 'rootDir' '/**/frontend/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Imported via '../../support/client' from file '/**/frontend/cypress/integration/EndToEndTests.spec.ts'
Matched by include pattern './**/*.ts' in '/**/frontend/cypress/tsconfig.json'ts(6059)
tsconfig.json(3, 15): File is matched by include pattern specified here.
【问题讨论】:
标签: typescript react-native configuration cypress