karma-runner / grunt-karma

Grunt plugin for Karma.
MIT License
468 stars 117 forks source link

start the server with grunt? #129

Open nofear87 opened 9 years ago

nofear87 commented 9 years ago

Is it possible to start the server with the grunt default task?

for exmaple in this way:

grunt.registerTask('default', ['karma:unit:start','open','concurrent:watchconnect']);

dignifiedquire commented 9 years ago

Yes that should be no problem, have you tried it?

LukasKraushofer commented 9 years ago

It's not working for me!

karma version: 0.13.7 grunt-karma version: 0.12.0

If I have a grunt Task like grunt.registerTask('test', ['karma:unit:start', 'watch:karma']); nothing happens. The first printed line in the console is

Running "watch:karma" (watch) task
Waiting...

the watch is working and is showing me which file has been changed and after 1 sec the console prints Done, without errors. even if there is a error inside the test file....

Here the Gruntfile tasks:

grunt.initConfig({

    watch: {
        karma: {
            files: ['<%= yeoman.app %>/**/*.spec.js', 'test/karma/**/*.js'],
            tasks: ['karma:continuous:run']
        }
    },

    karma: {
        options: {
            configFile: 'karma.conf.js'
        },
        unit: {
            singleRun: true
        }
    }

});

grunt.registerTask('test', ['karma:unit:start','watch:karma']);

and the karma.conf.js

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

        basePath: '',

        files: [
            // bower:js
            'bower_components/jquery/dist/jquery.js',
            'bower_components/angular/angular.js',
            'bower_components/angular-resource/angular-resource.js',
            'bower_components/angular-animate/angular-animate.js',
            'bower_components/angular-messages/angular-messages.js',
            'bower_components/angular-sanitize/angular-sanitize.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'bower_components/angular-ui-router/release/angular-ui-router.js',
            'bower_components/angular-local-storage/dist/angular-local-storage.js',
            'bower_components/angular-ui-tree/dist/angular-ui-tree.js',
            'bower_components/ng-file-upload/ng-file-upload.js',
            'bower_components/ng-file-upload-shim/ng-file-upload-shim.js',
            'bower_components/lodash/lodash.js',
            'bower_components/materialize/bin/materialize.js',
            'bower_components/angular-breadcrumb/release/angular-breadcrumb.js',
            'bower_components/angular-utils-pagination/dirPagination.js',
            'bower_components/angular-translate/angular-translate.js',
            'bower_components/angular-translate-loader-url/angular-translate-loader-url.js',
            'bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
            'bower_components/angular-translate-loader-partial/angular-translate-loader-partial.js',
            'bower_components/angular-toastr/dist/angular-toastr.tpls.js',
            'bower_components/google-code-prettify/bin/prettify.min.js',
            'node_modules/phantomjs-polyfill/bind-polyfill.js',
            // endbower
            'app/**/*.module.js',
            'app/**/*.js',
            'app/**/*.html',
            'test/karma/**/*.js'
        ],

        exclude: [],

        autoWatch: false,

        frameworks: ['jasmine'],

        browsers: ['PhantomJS'],

        preprocessors: {
            '**/*.html': 'ng-html2js',
            'app/**/*!(.spec).js': 'coverage'
        },

        reporters: ['progress', 'junit', 'coverage'],

        logLevel: config.LOG_INFO,

        singleRun: false,

        junitReporter: {
            outputDir: 'target/surefire-reports',
            suite: ''
        },
        coverageReporter: {
            dir: 'target/coverage/',
            reporters: [
                { type: 'cobertura', subdir: '.', file: 'cobertura.xml'},
                { type: 'lcov', subdir: '.', file: 'lcov.info'}
            ]
        },
        ngHtml2JsPreprocessor: {
            stripPrefix: 'app/',
            moduleName: 'template'
        }

    })
};