lundi 4 juin 2018

Mocha test.Timeout 2000ms

What I am doing wrong?I am trying to save phones to my db,but mocha says Timeout of 2000ms exceeded. My phone schema

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const phoneSchema = new Schema({
    company: String,
    modelname: String,
    numbername: String,
    picture: String,
    price: String,
});

const Phone = mongoose.model('phone', phoneSchema);

module.exports = Phone;

and my test file:

    const mocha = require('mocha');
const assert = require('assert');
const Phone = require('../models/phone-model');


//describe tests
describe('Saving records', function(){
    //create tests
    it('Saves phone to the db',function(done){

        var phone1 = new Phone({
            company: "Samsung",
            modelname: "Galaxy",
            numbername: "S5",
            picture: "https://drop.ndtv.com/TECH/product_database/images/2252014124325AM_635_samsung_galaxy_s5.jpeg",
            price: "12500P"
        });

        phone1.save().then(function(){
            assert(phone1.isNew === false);
            done(); 
        });

    });

});

I don't understand what I am doing wrong here..it always works for me before this. Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\Users\User\Desktop\Oauth\test\phone_test.js)

Aucun commentaire:

Enregistrer un commentaire