Jasmine tests on separate files without breaking the describe?

2

I want to organize my javascript tests on separate files, but these can be part of a common module. For example:

describe("Controllers", function () {

    describe('Move list Controller', function () {

        //ListController its
    });

    describe('Movie Detail Controller', function () {

        describe('must activate with', function () {
             //details controller its when activates
        });
        //other details controller's its

    });

    describe('Reserve Controller', function () {
         // reserve controller its
    });
});

I have describe('Controllers') , and under it all controllers. But here you can see how much the files will take as each controller will have several its . What I need is to break these tests into a file by controller , but still keeping them as part of describe('controllers')

I tried to call the same describe on different files and it generated redundancy:

Any idea how to separate into files without breaking describe ?

    
asked by anonymous 31.10.2014 / 13:06

1 answer

1

You can do this:

var parte = ['descrição', fnction(){ /* os it's aqui */ }]; // podes importar de outros arquivos

and then within each description within the describe('Controllers' flames these others describe with #

describe.apply(null, parte );

Example: link

var A = ['Parte A', function () {

    it('shoud pass the test A1', function () {
        expect(1).toEqual(1);
    });
    it('should pass the test A2', function () {
        expect(2).toEqual(2);
    });
}];
var B = ['Parte B', function () {

    it('shoud pass the test B1', function () {
        expect('b1').toEqual('b1');
    });
    it('should pass the test B2', function () {
        expect('b2').toEqual('b2');
    });
}];

describe('Controllers', function () {
    describe.apply(null, A);
    describe.apply(null, B);
});
    
31.10.2014 / 13:17