mardi 26 janvier 2016

Mean Web Development Haviv unit test

I'm going through the excellent Mean Web Development book by Amos Haviv. I have a unit test that tests the article object. It has an ObjectId reference to a user that is created in the beforeEach hook. In the afterEach hook it deletes both the Article and the User. However if I comment out these lines in the afterEach hook only the Article is saved without reference to the User? Could anyone explain why the Article remains in the local mean-test mongo db server and why the User doesn't?

I ran the test immediately after checking out Chapter 10's code and running npm install. I did nothing else bar commenting out the lines

// Define a post-tests function
afterEach(function(done) {
    // Clean the database
    //Article.remove(function() {
    //  User.remove(function() {
    //      done();
    //  });
    //});
    done();
});

Aucun commentaire:

Enregistrer un commentaire