简体   繁体   English

将 Chai 与 Jest + Typescript 结合使用

[英]Using Chai with Jest + Typescript

So, I'm trying to use chai expect library while running Jest with Typescript but I'm not being able to.因此,我在使用Typescript运行Jest时尝试使用chai expect 库,但我做不到。

What I'm actually trying to do is something similar to this: https://medium.com/@RubenOostinga/combining-chai-and-jest-matchers-d12d1ffd0303我实际上想做的是与此类似的事情: https ://medium.com/@RubenOostinga/combining-chai-and-jest-matchers-d12d1ffd0303

But I'm having no luck achieving this with Typescript .但是我没有运气用Typescript实现这一目标。 I'm quite new to the JS / TS, coming from C , Go and Swift , so I might be missing something here.我对 JS / TS 很陌生,来自CGoSwift ,所以我可能在这里遗漏了一些东西。

Can someone give me any directions to this this with TS while having autocomplete and no type errors working??有人可以在自动完成且没有类型错误的情况下使用 TS 给我任何指示吗? Thanks in advance!!提前致谢!!

PS: I'm using ts-jest PS:我正在使用ts-jest

I finally gave up and just "import { expect } from chai;"我终于放弃了,只是“从 chai 导入 {expect}”; in my spec files.在我的规格文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM