使用mocha测试包的正确结构是什么?

时间:2015-10-18 04:33:41

标签: meteor meteor-velocity

现在我有:

var express = require('express');
var bodyParser=require('body-Parser');  //comment this line
var morgan=require('morgan');           //comment this line
var app = express();
var http = require('http');             //comment this line

app.use(bodyParser.urlencoded({extended:true}));  //comment this line
app.use(bodyParser.json());                       //comment this line
app.use(morgan('dev'));                           //comment this line


app.get('/', function (req, res) {
res.send('Hello World!');
});

var ipaddress = process.env.OPENSHIFT_NODEJS_IP;
var port = process.env.OPENSHIFT_NODEJS_PORT;
if(typeof ipaddress === "undefined"){
ipaddress = "127.0.0.1";
port = 3000;
}
app.listen(port, ipaddress, function() {
// Do your stuff
console.log("Your server is running on: "+ipaddress+" port:"+port);
});

Package.describe({
  name: 'parlay:synapsepay',
  version: '0.0.1',
  summary: 'synapse_pay_rest for Meteor',
  git: 'https://github.com/parlaywithme/meteor-synapsepay',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('1.2.0.2');
  api.use('coffeescript');
  api.addFiles('synapsepay.coffee');
});

Package.onTest(function(api) {
  api.use('coffeescript');
  api.use('mike:mocha-package');
  api.use('parlay:synapsepay');
  api.addFiles('synapsepay-tests.coffee');
});

https://github.com/parlaywithme/meteor-synapsepay

我收到MochaWeb?.testOnly -> describe 'sanity', -> it 'is visible', -> chai.assert.isDefined SynapsePay 错误,正在运行

has no method 'testOnly'

meteor test-packages ./ 内:

packages/meteor-synapsepay

1 个答案:

答案 0 :(得分:2)

虽然目前记录不完整,但这个问题很容易解决:
只需抛弃describe 'sanity', -> it 'is visible', -> chai.assert.isDefined SynapsePay 并直接在测试文件中编写测试。

{{1}}

Mocha最初是为应用程序测试而设计的。使用它进行包装测试可能具有挑战性 当您运行测试时,您也可以see big Meteor.methods Match errors in the console。这是一个不应该干扰测试本身的常见问题。