xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.2k stars 375 forks source link

None of the tests work in node.js #162

Closed fresheneesz closed 11 years ago

fresheneesz commented 11 years ago

Yo, this is called node-xmpp. Why do all the tests look like they're written for a browser? I run them, and get ReferenceError: describe is not defined. This is lame.

lloydwatkin commented 11 years ago

Are you sure you've got your test system set up correctly?

If you look here https://travis-ci.org/astro/node-xmpp you'll see there are tests running for nodejs 0.6, 0.8, 0.9, 0.10

fresheneesz commented 11 years ago

I shouldn't have to have a test system set up. Once I npm install node-xmpp I should be able to run the tests straight away in node.js. There are no instruction about how to run the tests in node.js. The tests obviously have globally defined define and it functions - this is not node.js style, nor good practice. I take it you use jasmine for tests? Where are define and it supposed to be defined from?

lloydwatkin commented 11 years ago

Tests use mocha which installs as a devDependency (after all why install test frameworks in production).

fresheneesz commented 11 years ago

Damnit you're right. Sorry about being a dick - tho I still wouldn't think they'd work since I never got a "module 'mocha' not found error". I'll take your word for it and try tomorrow.

fresheneesz commented 11 years ago

@lloydwatkin So like I assumed, I get this when I npm install and run node tcp-test.js

Cannot load StringPrep-0.1.0 bindings. You may need to `npm install node-stringprep'

/home/vagrant/node-xmpp/test/tcp-test.js:6
describe("TCP client/server", function() {
^
ReferenceError: describe is not defined

Where are these tests supposed to be executed from?

lloydwatkin commented 11 years ago

Code uses mocha to run tests, not node directly. It follows standard semantics of running npm test from the command line. Here's what I get for latest version:

lloyd@zenbook:~/Dropbox/code/xmpp-ftw/node-xmpp$ npm test

> node-xmpp@0.7.1 test /home/lloyd/Dropbox/code/xmpp-ftw/node-xmpp
> mocha -R spec

  BOSH client/server
    client
      ✓ should go online (49ms)
      ✓ should send a stanza 
      ✓ should receive a stanza 

  JID
    parsing
      ✓ should parse a "domain" JID 
      ✓ should parse a "user@domain" JID 
      ✓ should parse a "domain/resource" JID 
      ✓ should parse a "user@domain/resource" JID 
      ✓ should parse an internationalized domain name as unicode 
      ✓ should parse an internationalized domain name as ascii/punycode 
      ✓ should parse a JID with punycode 
    serialization
      ✓ should serialize a "domain" JID 
      ✓ should serialize a "user@domain" JID 
      ✓ should serialize a "domain/resource" JID 
      ✓ should serialize a "user@domain/resource" JID 
    equality
      ✓ should parsed JIDs should be equal 
      ✓ should parsed JIDs should be not equal 
      ✓ should should ignore case in user 
      ✓ should should ignore case in domain 
      ✓ should should not ignore case in resource 
      ✓ should should ignore international caseness 

  TCP client/server
    client
      ✓ should go online (286ms)
      ✓ should send a stanza (39ms)
      ✓ should receive a stanza (40ms)

  23 passing (432ms)

lloyd@zenbook:~/Dropbox/code/xmpp-ftw/node-xmpp$ 

Also I note that mocha is in standard dependencies and not devDependencies I'll fix this in #165.

fresheneesz commented 11 years ago

Ah, all you need have said was npm test. I didn't even think of that. Please write how to run the tests in the readme so people like me don't waste their time. Thanks

ForestCho commented 10 years ago

you should key:mocha test.js