简体   繁体   English

将Jest与基于JSPM的应用程序集成

[英]Integrating Jest with JSPM based app

So I wanted to use Jest with my jspm project to write some unit tests, but it turned out it's not so easy... Well, it even turned out it's not so easy with any other testing framework. 所以我想在我的jspm项目中使用Jest来编写一些单元测试,但事实证明这并不容易...好吧,事实证明,使用任何其他测试框架都不那么容易。

How do I write tests for my jspm app? 如何为我的jspm应用编写测试? Which framework should I choose? 我应该选择哪个框架? Everything that I look up is quite complicated. 我查找的所有内容都很复杂。 I haven't found an easy solution. 我还没有找到简单的解决方案。 Every framework seems to require a bunch of workarounds to get things working in jspm setup. 每个框架似乎都需要大量变通办法,以使事情在jspm设置中起作用。 I feel kind of lost at the moment 我现在有点迷失

If not Jest, then what would be the least painful way of testing an app in jspm setup? 如果不是Jest,那么在jspm安装程序中测试应用程序最痛苦的方法是什么?

its true that without a 3rd party utility its not really possible to test a jspm based app with Jest. 的确,没有第3方实用程序,就不可能用Jest测试基于jspm的应用程序。 luckily, there's such a tool to help you do that: https://www.npmjs.com/package/gulp-jest-jspm (mine coincidentally) 幸运的是,有这样的工具可以帮助您做到这一点: https : //www.npmjs.com/package/gulp-jest-jspm (巧合的是我的)

You will need to install and use Gulp in order to run your tests 您将需要安装并使用Gulp才能运行测试

Ive been testing my own React app (built with JSPM) with Jest and its very straightforward. 我一直在用Jest测试我自己的React应用程序(使用JSPM构建),它非常简单。

I've found Jest to be very easy to learn and use. 我发现Jest非常易于学习和使用。 Let me know if you need more info 让我知道您是否需要更多信息

Yoav 约夫

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

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