lundi 29 février 2016

Karma Jasmine Runs Test Three Times

I am running Karma/Jasmine/Angular 2.0 tests on my development box. Just recently, Karma on my development box decided to start running my tests three times. Yes, exactly three times, every time.

On the first run, everything passes as expected. However, on the second and third pass, all of the same things fail. It always acknowledges that there are 7 tests, but runs 21, and 10 fail (first-grade math out the window)????

This also fails on Travis with SauceLabs. (Note: That links to an older build with 3 tests, but ran 9, and 5 fail???)

I have a screenshot, karma.conf.js file, and one suite which started this whole thing. Any help with be greatly appreciated.


Culprit [TypeScript] (Remove this and problem solved on my dev box):

describe('From the Conductor Service', () => {
    let arr: Array<ComponentStatusModel> = null;
    let svc: ConductorService = null;

    beforeEach(() => {  
        arr = [/* Inits the array*/];
        svc = new ConductorService();
    });

    describe('when it is handed a container to hold objects which need loaded', () => {
        // More passing tests...

        /// vvvvv The culprit !!!!!
        describe('then when you need to access the container', () => {
            beforeEach(() => {
                svc.loadedContainer = arr;
            });

            it('it should always be available', () => {
                assertIsLocalDataInTheService(arr, svc.loadedContainer);
            });
        });
        /// ^^^^^ End of culprit !!!!!
    });

    // More passing tests...
});

Failing Tests:

Tests are ran three times

Simplified karma.conf.js:

module.exports = function (config) {
    config.set({
        autoWatch: false,
        basePath: '.',
        browsers: ['Chrome'],
        colors: true,
        frameworks: ['jasmine'],
        logLevel: config.LOG_INFO,
        port: 9876,
        reporters: ['coverage', 'progress'],
        singleRun: true,

        coverageReporter: {
            // Code coverage config
        },

        files: [
            // Loads everything I need to work
        ],

        plugins: [
            'karma-chrome-launcher',
            'karma-coverage',
            'karma-jasmine'
        ],

        preprocessors: {
            'app/**/*.js': ['coverage']
        },

        proxies: {
            // Adjust the paths
        }
    })
}

Aucun commentaire:

Enregistrer un commentaire