所以我正在和我的express.js项目一起玩BDD和摩卡车.我刚刚开始,所以这里是我作为我的第一个测试案例:
should = require "should" require "../lib/models/skill.js" describe 'Skill',-> describe '#constructor()',-> it 'should return an instance of class skill',-> testSkill = new Skill "iOS","4 years",100 testSkill.constructor.name.should.equal 'Skill'@H_403_3@(也是这个coffeescript生成一些奇怪的js,因为它插入返回到最后一个语句..这是使用coffeescript设置测试的正确方法?)
现在,当我运行摩卡我得到这个错误:
1) Skill #constructor() should return an instance of class skill: ReferenceError: Skill is not defined@H_403_3@我认为我的意思是skill.js没有正确导入.我的技能类在这一点上非常简单,只是一个构造函数:
class Skill constructor: (@name,@years,@width) ->@H_403_3@如何导入我的模型,以便我的摩卡测试可以访问它们?