lundi 2 février 2015

Can't run a test under vows?

I'm trying to follow the unit testing scheme on an open source project, and I don't entirely understand what I'm doing wrong. I have the following:



vows = require 'vows'
assert = require 'assert'
phantom = require '../phantom'

describe = (name, bat) -> vows.describe(name).addBatch(bat).run()

# Make coffeescript not return anything
# This is needed because vows topics do different things if you have a return value
t = (fn) ->
->
fn.apply this, arguments
return

describe "The phantom module (error behavior)",
"Cannot create an instance at a nonexistent path":
topic: t ->
phantom.create {port: 12302, path: "./test/dir-does-not-exist"}, (ph, err) =>
@callback null, [ph, err]

"which is null": ([ph, err]) ->
assert.isNull ph


Before, I had addBatch(bat).export(module), which followed the style of existing tests, but when I tried to run the whole thing, all it printed was:



vows runner running The phantom module (error behavior)


and nothing else. So I changed it to .run() in order to run it as an individual file, and instead I get



➜ phantomjs-node git:(master) ✗ coffee test/error.coffee
Could not find any tests to run.%


I believe that I'm following the docs, which say that



vows.describe('subject').addBatch({/* ... */}).run();


is "the simplest way to run a test suite." My test follows the same format as the existing tests, so I assume that the body of my batch is fine.


What am I doing wrong?


Aucun commentaire:

Enregistrer un commentaire