2

最初beforeEachは User コレクションをクリアします...これは、最初の一連のテスト (#save() describe) では正常に機能しますが、2 番目の describe("#find()") では機能しません。

describe('User', function(){
    beforeEach(function(done){
        //clear out db
        User.remove(done);
    });

    describe('#save()', function(){

        beforeEach(function(done){
            user = new User(fakeUser);
            done();
        });

        it('should have username property', function(done){
        });


        it('should not save if username is not present', function(done){
        });
    });

    describe('#find()', function(){
        beforeEach(function(done){
            user = new User(fakeUser);
            user.save(function(err, user){
                done();
            });
        });

        it('should find user by email', function(done){
        });

        it('should find user by username', function(done){
        });
    });
});

最初のbeforeEach は何を指していますか? 子供ごとに実行されると思っていましdescribeたが、どうやらそうではありません。

4

1 に答える 1

0

残念ながらafter、コレクションを削除するには追加する必要がありました。

于 2012-11-12T07:41:25.627 に答える