简体   繁体   English

如何使用Mocha,Grunt测试NodeJS应用程序?

[英]How to test NodeJS application using Mocha, Grunt?

Maybe someone met any npm module/tutorial/guide/article about "how to test nodejs application using mocha, gruntjs?" 也许有人遇到任何关于“如何使用mocha,gruntjs测试nodejs应用程序”的npm模块/教程/指南/文章? Would be glad to any suggestions. 任何建议都会很高兴。

I'd recommend the following (it worked for me): 我推荐以下(它对我有用):

  1. Install Grunt and get your first sample grunt task running based on the Grunt documentation 安装Grunt并根据Grunt文档运行第一个示例grunt任务
  2. Use this grunt task to get server-side Grunt running Mocha tests for you, and this one for client-side tests. 使用这个grunt任务让服务器端Grunt为你运行Mocha测试, 这个用于客户端测试。 From the command line, you can just run $ grunt to watch the results pop up. 从命令行,您只需运行$ grunt即可弹出结果。
  3. At this point, you can check out Mocha interfaces for samples of how your tests can look. 此时,您可以查看Mocha界面 ,了解测试的外观样本。 Note that there's also should.js , if you're big on rSpec-style tests. 请注意,如果您对rSpec样式的测试很重要,那么还有should.js Once you've settled on an interface, more Googling/StackOverflowing is the best way to proceed (eg Google "Mocha should.js examples"). 一旦你确定了界面,更多的谷歌搜索/ StackOverflowing是最好的方法(例如Google“Mocha should.js examples”)。

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

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