I am trying to implement a very basic unit test for CoffeeScript/JavaScript with JsTestDriver. I've got two files:
1.) lib/Greeter.coffee
greet = (name) ->
"Hello #{name}"
2.) lib/GreeterTest.coffee
tests = {
"Test 1": -> assertEquals("Hello World!", greet "World")
}
TestCase("Test for introducing the test framework", tests)
My jsTestDriver.conf defines their path with the line: - lib/*.js
When executing the test, however, I get: Total 0 tests (Passed 0; Fails: 0; Errors: 0)
I am sure, that the test can be located, because inserting an obvious program error leads to the detection that error in the concrete file. Also inserting an alert invocation leads to the expected behavior: In the browser being captured I see the alert-Message Box
Am I missing something? How could something like this be debugged?
What does work though is the following:
TestCase("Test case 1", {
testGreet: ->
greeter = new Greeter
assertEquals("Hello World!", greeter.greet "World")
})
and
class @Greeter
constructor: ->
greet: (name) ->
return "Hello #{name}!"
If both files reside in the same folder, you can drop the @