Node.js 摩卡咖啡&x27;应该';-与';should.equal()';但会导致不必要的资产错误

Node.js 摩卡咖啡&x27;应该';-与';should.equal()';但会导致不必要的资产错误,node.js,mocha.js,should.js,Node.js,Mocha.js,Should.js,我从摩卡收到这个错误: Uncaught AssertionError: expected 'long-title-abcdefghijklmnopqrs' to equal 'long-title-abcdefghijklmnopqrs' 这没有任何意义,因为这些字符串看起来是相等的。以下是测试代码: it('shortens and joins title to 30 characters and with -', function(done){ article.createMdA

我从摩卡收到这个错误:

Uncaught AssertionError: expected 'long-title-abcdefghijklmnopqrs' to equal 'long-title-abcdefghijklmnopqrs'
这没有任何意义,因为这些字符串看起来是相等的。以下是测试代码:

it('shortens and joins title to 30 characters and with -', function(done){
    article.createMdArticle('long title abcdefghijklmnopqrstubwxyz', 'the bod', function(err, doc){
      if(err) throw err;
      doc.url_title.should.eql('long-title-abcdefghijklmnopqrs');
      done();
    })
})
这个mongoose pre('save')钩子从标题创建url\u标题

articleSchema.pre('save', function (next) {
    //makes 'test title' into 'test-title'
    this.url_title = this.title.split(' ').join('-').substring(0,30);
    console.log(this.url_title);
    next();
});

我的所有其他测试都比较了任何其他对象数据,结果与预期一致。。。在我的文章schema mongoose schema中

var articleSchema = new Schema({
    title : { type: String, index: { unique: true, required: true }},
    body: { type: String, required: true },
    url_title: { sype: String},
});
url\u title
行上,它显示的是
sype:String
,而不是
type:String
。当我纠正这一点时,错误不再存在