简体   繁体   English

摩卡柴或开玩笑或两者兼而有之?

[英]Mocha Chai or JEST or BOTH?

Sorry this might be off topic question but I'll ask it anyway.抱歉,这可能是题外话,但我还是会问的。

I am a newbie and I was thinking about test driven development.我是新手,我在考虑测试驱动开发。

Can you use jest for testing node/express?你能用 jest 来测试 node/express 吗? Or do you need to use mocha for node/express and jest separately for react?或者您是否需要将 mocha 用于 node/express 并分别使用 jest 进行反应?

trying to learn MERN stack.尝试学习 MERN 堆栈。

You can use Jest, it is a replacement for Mocha.你可以使用 Jest,它是 Mocha 的替代品。

Sorry this might be off topic question but I'll ask it anyway.抱歉,这可能是题外话,但我还是会问。

I am a newbie and I was thinking about test driven development.我是一个新手,我正在考虑测试驱动开发。

Can you use jest for testing node/express?你能用 jest 测试 node/express 吗? Or do you need to use mocha for node/express and jest separately for react?或者您是否需要将 mocha 用于 node/express 和 jest 分别用于反应?

trying to learn MERN stack.尝试学习 MERN 堆栈。

It is possible to use Jest for node / express development.可以使用 Jest 进行节点/快速开发。 However, you will probably find the development process more painless when using mocha and chai (I tried using jest on the backend once, but we felt that we were fighting with the tooling too much for the frontend / backend consistency to be useful, and we ultimately switched everything over to mocha in the end).但是,您可能会发现使用 mocha 和 chai 时开发过程更加轻松(我曾尝试在后端使用 jest 一次,但我们觉得我们在使用工具时对前端/后端一致性有用,我们最终最终将所有内容都切换到了摩卡)。

It's quite easy to get started...上手很容易...

Just install the dependencies:只需安装依赖项:

npm i --save-dev mocha chai

add add a script in your pakage.json file to run the tests:pakage.json文件中添加一个脚本来运行测试:

mocha **/*.test.js

Good luck!祝你好运!

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

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