我试图使用Cypress w/ the成绩单,但是Cypress找不到我为它创建的tsconfig.json文件。我还有一个定制的目录结构(因为我讨厌根目录中有一堆配置文件,所以我把它们放在一个config目录中)。
项目目录结构
/
├── package.json
├── configs/
│ ├── cypress.json
├── src/
│ ├── cypress/
│ │ ├── tsconfig.jsonCypress打开命令
// package.json
"scripts": {
"cypress:open": "cypress open --config-file configs/cypress.json"
},在上面的脚本中,--config-file标志告诉cypress cypress.json配置文件的位置,这很棒,因为我可以将该文件放在任何我想要的位置。但是,现在我需要告诉Cypress在哪里可以找到它的tsconfig.json文件。
/configs/cypress.json (告诉Cypress cypress/目录在哪里)
{
"fixturesFolder": "src/cypress/fixtures",
"integrationFolder": "src/cypress/integration",
"pluginsFile": "src/cypress/plugins/index.js",
"screenshotsFolder": "src/cypress/screenshots",
"videosFolder": "src/cypress/videos",
"supportFile": "src/cypress/support/index.js"
}
// is there no option to set tsconfig.json path????正式文件要求将其放在cypress/目录中。根据文档,应该在/cypress/tsconfig.json,但在我的项目中,它是在/src/cypress/tsconfig.json。
下面是我尝试放置tsconfig.json文件的位置:
/src/cypress/tsconfig.json //Error: "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
/src/tsconfig.json //Error: "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
/cypress/tsconfig.json //Error: "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
/tsconfig.json // Works!! But not where I want this file to live...如何指示Cypress在何处查找我希望它使用的tsconf.json文件?cypress.json配置文件中是否有选项,或我可以使用的CLI标志?
我不想让我的项目根上杂乱无章的配置文件,我实际上有我的项目和我的测试套件的单独的tsconfig文件。显式设置文件路径将是很好的。
发布于 2021-07-11 15:48:49
虽然这不是您希望听到的答案,但tsconfig.json将目录标记为类型记录项目的根目录,就像package.json将目录标记为node.js项目的根一样。这些文件有助于像IDE这样的工具来理解您的项目。
在我看来,只有当您开始将tsconfig.json放在其他文件夹中时,才应该考虑移动package.json。
另见:https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
发布于 2020-10-06 15:16:01
请参阅柏树真实世界应用程序,用于演示Cypress测试方法、模式和工作流的实际使用情况的支付应用程序。。
它是用创建-反应-应用程序和TypeScript构建的。用于柏树的tsconfig.json位于目录中。
您可能需要配置根tsconfig.json并从柏树tsconfig.json扩展它,就像在RWA中所做的那样。
// cypress/tsconfig.json
{
"extends": "../tsconfig.json",
// ...
}发布于 2021-03-30 05:18:08
如果此命令有效,请试一试:
//CD to the space you want your .tsconfig
cd project_config
// Create .tsconfig
tsc --init
// Specify were you want to run your tsconfig file from
tsc -p /path/to/folder/with/tsconfig https://stackoverflow.com/questions/64141729
复制相似问题