使用开玩笑和柏树与打字稿引起断言和开玩笑的错误
While using [email protected] with Jest, we are facing Assertion and JestMarchers typescipt errors. Why are we facing typescipt errors while working with Jest and [email protected] in the some project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 [email  procationed] with jest] with jest,我们面临的类型错误。有解决方案。
开玩笑和柏树正在使用相同的库,因此在编写单元测试时,这可能会在嘲笑中引起打字条问题。
为了解决这个问题,我们需要两个tsconfig.json文件。一个用于root tsconfig.json,另一个用于
root tsconfig.json文件中的./cypress/tsconfig.json。
另外,在root tsconfig.json文件中,请确保添加类型:“ type”:[“ jest”,“@types/testing-library__jest-dom”]。
请调查root tsconfig.json文件。
tsconfig.json
在./cypress/tsconfig.json文件中,请确保您将root tsconfig.json文件扩展了,然后将cypress.config.ts添加到文件中。
另外,您还需要确保不排除.cypress/tsconfig.json文件中的柏树。
请调查以下内容./cypress/tsconfig.json文件。
./ cypress/tsconfig.json
这是您需要遵循的最后一个更新;
在root项目文件夹中,您应该创建jest.d.ts文件,以添加一些类型的定义,这些定义在使用柏树时不会以某种方式提供这些定义。
如果您不提供此文件,则可以获得JestMatchers TS错误。
jest.d.ts file
注意:如果您的项目的柏树版本小于cypress@10,您需要首先将柏树版本升级到 [email  procearted] 通过遵循默认的默认CYPRESS迁移建议。
While using [email protected] with Jest, we are facing typescript errors. There are solutions for that.
Jest and Cypress are using same libraries so this can cause typescript problems in test files in Jest while writing unit tests.
To solve this problem we need two tsconfig.json files. One is for root tsconfig.json and the another one for ./cypress/tsconfig.json
In the root tsconfig.json file be sure that you excluded cypress and cypress.config.ts file.
Also in the root tsconfig.json file be sure that add types: "types": ["jest", "@types/testing-library__jest-dom"].
Please investigate root tsconfig.json file.
tsconfig.json
In the ./cypress/tsconfig.json file, be sure that you extended root tsconfig.json file and you add cypress.config.ts to file.
Also you need to be sure that you do not exclude cypress in .cypress/tsconfig.json file.
Please investigate following ./cypress/tsconfig.json file.
./cypress/tsconfig.json
This is the last update you need to follow;
In the root project folder you should create jest.d.ts file to add some type definitions which Jest does not provide somehow while working with cypress.
If you do not provide this file you can get JestMatchers ts errors.
jest.d.ts file
Note: If your project's cypress version less than cypress@10 you need to first upgrade cypress version to [email protected] by following default cypress migration suggestions.
遇到了同样的问题,我删除了
cypress.config.ts
文件,ranjest test
成功,并添加了cypress.config.ts
归档。它在这些步骤之后开始工作Had the same issue, I deleted the
cypress.config.ts
file, ranjest test
with success, and added thecypress.config.ts
file back in. It started working after those steps