Reputation: 43639
Not sure why I'm getting an error:
'use strict';
/**
* Module dependencies.
*/
var should = require('should'),
mongoose = require('mongoose'),
Block = mongoose.model('Block');
//Globals
var block;
//The tests
describe('<Unit Test>', function() {
describe('Model Block:', function() {
beforeEach(function(done) {
block = new Block({
bits: "1d00ffff",
block_fee: 0,
blockreward: 50,
coinbase: 50,
difficulty: 1,
fees_claimed: 0,
fees_paid: 0,
hash: "000000005c51de2031a895adc145ee2242e919a01c6d61fb222a54a54b4d3089",
height: 13,
merkleroot: "9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271",
nextblockhash: "0000000080f17a0c5a67f663a9bc9969eb37e81666d9321125f0e293656f8a37",
nonce: 2259603767,
previousblockhash: "0000000027c2488e2510d1acf4369787784fa20ee084c258b58d9fbd43802b5e",
size: 215,
time: 1231475020,
time_to_confirm: 132,
tx: [
"9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271"
],
txcount: 1,
version: 1,
vin_total: 0,
vout_total: 50
});
});
describe('Method Save', function() {
it('should be able to save without problems', function(done) {
return block.save(function(err) {
should.not.exist(err);
done();
});
});
it('should be able to show an error when try to save without hash', function(done) {
block.hash = '';
return block.save(function(err) {
should.exist(err);
done();
});
});
});
afterEach(function(done) {
Block.remove({});
done();
});
after(function(done) {
Block.remove().exec();
done();
});
});
});
That's my model.js
test file. The error I get is:
<Unit Test>
Model Block:
Method Save
1) "before each" hook
0 passing (2s)
1 failing
1) <Unit Test> Model Block: "before each" hook:
Error: timeout of 2000ms exceeded
Not sure why it's taking 2 seconds or WHAT is taking 2 seconds. How can I see why something is taking that long?
Upvotes: 0
Views: 1860
Reputation: 151531
It is telling you what took so long. This message:
<Unit Test> Model Block: "before each" hook:
corresponds to this beforeEach
call:
describe('<Unit Test>', function() {
describe('Model Block:', function() {
beforeEach(function(done) {
block = new Block({
//....
If you want to know why it takes so long, you can put a breakpoint on the line where new Block
executes and step through it.
Upvotes: 1