Pregunta

I'm running Geddy MVC Framework on Node.js on Heroku right now with a Postgres database. I can't seem to find any unit test frameworks for node.js that support Geddy. I have tried nodeunit, jasmine and a couple others but none seem to work with geddy (saying it is undefined - I think because it doesn't know how to import all of the required files).

I know Geddy provides their jake test tool but it doesn't seem to work either. It gives me this output:

ReferenceError: geddy is not defined

Any help would be greatly appreciated. Also looking for a code coverage tool that will work with the unit testing framework I get working.

Thanks!

EDIT: My tests all start with this header to import the required modules:

var assert = require('assert')
  , tests
  , Activity = geddy.model.Activity;

And the import of Activity fails with the ReferenceError above, so it never even tries my tests.

Here is a nodeunit test I wrote

var tests
  , User = geddy.model.User;

exports['addUser1'] = function (test) {
    var user = User.create({username: 'Greg',
                        password: 'MyPassword!',
                        confirmPassword: 'MyPassword!',
                        familyName: 'LastName1',
                        givenName: 'FirstName1',
                        email: 'Greg@greg.com'});
User.add(user, function (answerDict) {
    test.equal(answerDict, {'errCode': 1});
    test.done();
});
};

And the output

...../test/test-user.js:2
  , User = geddy.model.User;
           ^
ReferenceError: geddy is not defined
.....

EDIT: Thought I'd post a direct link to the solution here. After some help on the github issue tracker, I was able to get testing and code coverage to work. I have a small write-up and link to example code too here: https://github.com/mde/geddy/wiki/Unit-Testing-&-Code-Coverage-With-Geddy

¿Fue útil?

Solución 2

This was raised as an issue. Please follow up there. I'll update the answer once the issue is resolved.

Otros consejos

Can you explain briefly with a sample code. Did you try the frameworks vows or mocha

Here is the full list of testing frameworks. Have a look on it.

Testing Frameworks

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top