2012-11-28 59 views
4

如何使用jasmine-node和RequireJS正确运行茉莉花测试?如何使用RequireJS运行茉莉花节点测试

我已经尝试过这样的事情,但不工作(CoffeeScript的):

requirejs = require 'requirejs' 
requirejs.config { baseUrl: __dirname + '/../' } 

requirejs ['MyClasses', 'FooClass'], (MyClasses, FooClass) -> 

    describe "someProp", -> 
    it "should be true", -> 
     expect(MyClasses.FooClass.someProp).toEqual true 

0秒0的测试,0断言,0失败

我的目标是编写模块化类成品使用RequireJS,CoffeeScript和类必须使用jasmine-node(CI服务器)进行测试。

我该怎么做? 谢谢!

编辑:

我执行与命令测试(在目录与测试):

jasmine-node ./ 
+0

你是怎么执行茉莉花的?如果你在'requirejs'块中放置一个'console.log'hello',它会打印吗?在'它'里面?在requirejs块之外怎么样? –

+0

requirejs块的'Outside'将首先打印“hello”。第二个是“require”内部的“hello”块,“it”块中的“hello”不打印。 –

+1

你尝试过'jasmine-node --coffee --verbose。/'?另外,你的spec文件名为?我认为它必须在“Foo.spec.coffee”中包含“spec”作为名称的一部分。 –

回答

0

Jonathan Tran是对的,这是我的文件名中的规格。

我有这样的:

"scripts": { 
    "install": "cake install", 
    "test": "node_modules/jasmine-node/bin/jasmine-node --verbose --coffee --runWithRequireJs --captureExceptions spec" 
}, 
在我的package.json

,我从项目npm install jasmine-node

最小的测试文件名为RingBuffer.spec.coffee

require ["disrasher"], (mod) -> 

    describe "A test", -> 
    it "should fail", -> 
     expect(1).toEqual 0 

一点也没有”内部安装茉莉节点实际上目前工作,因为我没有得到项目挂钩需要适当我不认为。当它发生时我会回到这里。