问题描述
我对帆,节点和js完全陌生,所以我可能会遗漏一些明显的东西.
I'm completely new to sails, node and js in general so I might be missing something obvious.
我正在使用帆0.10.5和节点0.10.33.
I'm using sails 0.10.5 and node 0.10.33.
在sails.js文档中,有一个有关测试的页面 http://sailsjs.org/# /documentation/concepts/Testing ,但它没有告诉我如何实际运行它们.
In the sails.js documentation there's a page about tests http://sailsjs.org/#/documentation/concepts/Testing, but it doesn't tell me how to actually run them.
我已经根据该文档设置了目录,添加了一个名为test/unit/controllers/RoomController.test.js的测试,现在我希望它可以运行.
I've set up the directories according to that documentation, added a test called test/unit/controllers/RoomController.test.js and now I'd like it to run.
没有"sails test"命令或类似命令.我也没有发现有关如何添加任务的迹象,因此测试总是在吊索"之前进行.
There's no 'sails test' command or anything similar. I also didn't find any signs on how to add a task so tests are always run before a 'sails lift'.
推荐答案
在we.js中查看我的测试结构: https://github.com/wejs/we-example/tree/master/test
See my test structure in we.js: https://github.com/wejs/we-example/tree/master/test
您可以复制并粘贴到sails.js应用程序中,并删除bootstrap.js中的we.js插件功能
You can copy and paste in you sails.js app and remove we.js plugin feature in bootstrap.js
然后将您的package.json更改为在npm测试中使用设置正确的mocha命令: https://github.com/wejs/we-example/blob/master/package.json#L10
And change you package.json to use set correct mocha command in npm test: https://github.com/wejs/we-example/blob/master/package.json#L10
-编辑-
我创建了一个简单的sails.js 0.10.x测试示例,请参见: https://github.com/albertosouza/sails-test-example
I created a simple sails.js 0.10.x test example, see in: https://github.com/albertosouza/sails-test-example
这篇关于Sails.js:如何实际运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!