0
我有以下test.js文件。從js文件執行命令來創建sails應用程序
test.js
var assert = require('assert');
var path= require('path');
exec('pwd') //Display current Dir
exec('sails new App') //Create New Sails App
exec('cd App') //Change to App Directory
exec('sails new generate model alpha') //Generate Model
exec('sails new generate controller alpha') //Generate Controller
describe('Test controller created or not ', function(){
it('Equal with Controller Directory Path', function(done){
assert.equal(path.resolve('api/controller/','Alphacontroller') , path.resolve('api/controller/','Alphacontroller'));
done();
});
});
所以,如果
Run $ Mocha test.js
應該創建應用程序,生成模型,控制器,檢查控制器是否創建或不
我使用摩卡作爲我的測試框架。
由於@bredikhin注意下面,發電機在框架中測試。另外,'sails new generate model alpha'不會做你期望的 - 它會創建一個名爲「generate」的新應用程序。生成模型只是'sails generate model [modelName]';對於控制器,它是'sails generate controller [controllerName]' – sgress454