jimivdw / grunt-mutation-testing

JavaScript Mutation Testing as grunt plugin. Tests your tests by mutating the code.
MIT License
50 stars 11 forks source link

mutation testing not working for Karma #3

Closed milindk740 closed 9 years ago

milindk740 commented 9 years ago

Hi All, for some reason this plugin does not seem to be working for karma. I debugged and what I could see is the server does not start. It always gives a error that "No server is running on ". I tried the plugin for mocha it seems to be working fine. But for karma it does not work. following is the code added to the grunt file -

    mutationTest: {
        karma: {
            options: {
                karma: {
                    configFile: 'node_modules/grunt-mutation-testing/test/fixtures/karma-mocha/karma.conf.js',
                    waitForServerTime: 5 // optional, default = 5s
                }
            },
            files: {
                'tmp/karma.txt': ['node_modules/grunt-mutation-testing/test/fixtures/karma-mocha/script*.js']
            }
        }
    },

Following is the content of the conf file -

// Karma configuration // Generated on Wed Apr 30 2014 16:43:43 GMT+0200 (CEST)

    module.exports = function (config) {
        config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '../',

        /**
         * This is the list of file patterns to load into the browser during testing.
         */
        files: [
            'node_modules/grunt-mutation-testing/test/fixtures/karma-mocha/script*.js',
            'node_modules/grunt-mutation-testing/test/fixtures/karma-mocha/karma-test.js'
        ],

        frameworks: [ 'jasmine' ],
        plugins: [ 'karma-jasmine', 'karma-firefox-launcher', 'karma-chrome-launcher', 'karma-coffee-preprocessor', 'karma-coverage' ],

        // list of files to exclude
        exclude: [
            //'app/scripts/sidebar.js'
        ],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage'],

        port: 9876,
        runnerPort: 9100,
        urlRoot: '/',

        /**
         * Disable file watching by default.
         */
        autoWatch: false,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Firefox'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false

    }
)
;

} ;

Following is the output of the karma.txt file -

   Tests fail without mutations.

Let me know if anyone can help.

jimivdw commented 9 years ago

Hi,

Sorry to have let you wait for a response for such a long time. The project had gotten quite inactive and has recently been taken over by me and some others, hence we're only able to answer your question now.

It appears that you are trying to run the project's unit tests with the project's unit test settings from within your project (given that you've set the Karma configFile to 'node_modules/grunt-mutation-testing/test/fixtures/karma-mocha/karma.conf.js' and the mutationTest files to ['node_modules/grunt-mutation-testing/test/fixtures/karma-mocha/script*.js']). Why exactly are you trying to do this? If you want to run the project's unit tests, you should run npm test inside a clone of the project repository.

If, however, you are trying to run the mutation tests on your project, you need to provide the correct settings:

Hope this helps you out, or that you figured it out yourself in the meantime.

-- Jimi

paysdoc commented 9 years ago

I don't see any more activity here so I'm going to close this issue