Created
July 20, 2012 20:07
-
-
Save PolCPP/3152917 to your computer and use it in GitHub Desktop.
Strange behavior with mocha/chai/sequelize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chai = require "chai" | |
crypto = require "crypto" | |
Sequelize = require "sequelize" | |
chai.should() | |
sequelize = new Sequelize 'talk', 'root','root', { | |
host: 'localhost' | |
logging: false | |
} | |
User = sequelize.define 'User', { | |
name: type: Sequelize.STRING, | |
key: type: Sequelize.STRING, | |
level: type: Sequelize.INTEGER, defaultValue: 0 | |
}, instanceMethods: { | |
addKey: (key) -> | |
this.key = crypto.createHash('md5').update(key).digest("hex"); | |
} | |
describe 'User instance', -> | |
it 'Should insert to db', (done) -> | |
user1 = User.build { name: 'John Doe' } | |
user1.save().success -> | |
# Let's make it fail from here | |
user1.id.should.equal null | |
done() | |
it 'Should insert to db', (done) -> | |
user1 = User.build { name: 'John Doe' } | |
user1.save().success -> | |
user1.id.should.not.equal null | |
done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PolCPP$ mocha --compilers coffee:coffee-script -R spec | |
User instance | |
1) Should insert to db | |
2) Should insert to db | |
✖ 2 of 2 tests failed: | |
1) User instance Should insert to db: | |
expected 89 to equal null | |
2) User instance Should insert to db: | |
Error: timeout of 2000ms exceeded | |
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runnable.js:142:14) | |
at Timer.ontimeout (timers.js:94:19) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chai = require "chai" | |
crypto = require "crypto" | |
Sequelize = require "sequelize" | |
chai.should() | |
sequelize = new Sequelize 'talk', 'root','root', { | |
host: 'localhost' | |
logging: false | |
} | |
User = sequelize.define 'User', { | |
name: type: Sequelize.STRING, | |
key: type: Sequelize.STRING, | |
level: type: Sequelize.INTEGER, defaultValue: 0 | |
}, instanceMethods: { | |
addKey: (key) -> | |
this.key = crypto.createHash('md5').update(key).digest("hex"); | |
} | |
describe 'User instance', -> | |
it 'Should insert to db', (done) -> | |
user1 = User.build { name: 'John Doe' } | |
user1.save().success -> | |
user1.id.should.not.equal null | |
done() | |
it 'Should insert to db', (done) -> | |
user1 = User.build { name: 'John Doe' } | |
user1.save().success -> | |
user1.id.should.not.equal null | |
done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mocha --compilers coffee:coffee-script -R spec | |
User instance | |
✓ Should insert to db | |
✓ Should insert to db | |
✔ 2 tests complete (28ms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment