GithubHelp home page GithubHelp logo

gulp-karma's Introduction

gulp-karma's People

Contributors

clkao avatar lazd avatar patrickjs avatar ryan-roemer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-karma's Issues

Uncaught Error: Mismatched anonymous define() module

I'm trialling gulp-karma with the same karma.conf.js file that we use for our existing grunt karma task and running into issues. Following the suggestion to explicitly specify plugins to solve Error: No provider for "framework:jasmine" [https://github.com//issues/4] I'm now receiving an "Uncaught Error: Mismatched anonymous define() module: function (... " error message for every spec.

I can see from debugging in chrome that none of our Spec dependencies (jquery, underscore etc) as defined in our test-main.js file are being loaded. Other than learning the internals of require.js I'm stuck.

"Adapter did not report total number of specs."

I've ran into an issue where Karma isn't reporting the total number of tests, even though it is successfully running the tests and reporting back if they have succeeded or failed.

For example, it will run and give me the message "Adapter did not report total number of specs" followed by "Executed 2 of 0. SUCCESS".

While running the karma.conf.js with Karma alone - it appears to correctly calculate the number of tests correctly and the adapter message is not displayed. I have searched around and I have been unable to find anyone else with the same issue. So, I'm afraid that I have either missed a step when setting up Karma in my gulpfile or there may be a bug in the plugin.

Can you take a look at this?

gulpfile.js

gulp.task('tests', function() {
    return gulp.src('./tests/unit-tests.js')
        .pipe(karma({
            configFile: 'karma.conf.js', 
            action: 'run'
        }));
});

karma.conf.js

module.exports = function(config) {
  config.set({
    basePath: '',
    plugins: [
      'karma-qunit',
      'karma-phantomjs-launcher'
    ],
    frameworks: ['qunit'],
    // files: [
    //   'tests/*.js'
    // ],
    exclude: [

    ],
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['PhantomJS'],
    captureTimeout: 60000,
    singleRun: false
  });
};

Thanks!

Paths to exclude files

Hi! From your Readme:

options.*

Any Karma option can be passed as part of the options object. See [Karma Configuration] for a complete list of options. Note: It's best practice to put options in your Karma config file.

I'm trying to pass paths for exclude files from tests(karma.config.js has exclude property). It doesn't work. Files are not excluded. If i keep exclude paths in karma.conf.js all works fine, but i want to keep all paths (files for testing and for excluding) in one place (gulpfile.js)

What the best practice to do that with gulp-karma plugin?

The part of my gulpfile.js below:

...
var paths = {
    tests: {
        frontend: [
            srcPath + '/js/**/*.js',
            testsPath + '/helpers.js',
            testsUnitPath + '/**/*.js'
         ],
        exclude: [
            srcPath + '/js/*.min.js',
            testsUnitPath + '/server.js'
        ]
    }
};

gulp.task('run-tests', function() {
    return gulp
            .src(paths.tests.frontend)
            .pipe(karma({
                configFile: testsPath + '/karma.config.js',
                action: 'run',
                exclude: paths.tests.exclude
            }))
            .on('error', function(err) {
                throw err;
            });
});
...

Does not work with Karma 0.13.0

When trying to run this with newer version of karma, I receive the following error:

/home/ubuntu/web-costa-de/node_modules/karma/lib/index.js:11
    throw new Error(
          ^
Error: The api interface has changed. Please use 
  server = new Server(config, [done])
  server.start()

I can submit a PR if that helps but I see this project seems to have gone stale.

No exit-code/errorlevel on task exit

Using the "helper" branch.

I am running the following code:

gulp.task('test', function () {
    return karma.start({
        singleRun: true,
        browsers: ["Chrome"]
    });
});

When running gulp test the returned result code is 0 even if the test fails.

Pulling file list from karma.conf.js

I've been trying to figure out a way to use my existing karma.conf.js file that already has a list of the test files.

Is there a way to pull the files property from the karma.conf.js file without having to put the file list in my gulp.js file?

What does input source do when all files are defined in the config?

More of a question...

If I define all my .spec.js and .js files in the karma config file... what files should I be piping in and what effect they they have?

i tried it with a null set, but that throws. And no matter what I set as source, it runs all the tests.

Sort of confusing syntax..

Any explanation?

thanks

--mike

"spawn ENAMETOOLONG" Error in Windows with many test files

We're using gulp-karma package and now we're starting to get plenty of test files in our project. We've started getting the error "spawn ENAMETOOLONG" which probably can be related to limits with Windows. The error goes away if we move to project to a destination that has shorter path. I belive it's simlar problem they had here: dbushell/grunt-svg2png#17 .

Is there a fix or work around for this issue?

Error message:

[14:20:19] Starting Karma server...

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENAMETOOLONG
    at errnoException (child_process.js:1001:11)
    at Process.ChildProcess._handle.onexit (child_process.js:792:34)

What's the point in giving .src() ?

Why does this plugin require src files to test when they are already specified in the karma conf -- that's the whole point of the conf. Just wondered the logic behind this...

gulpfile.js

return gulp.src(testFiles)
    .pipe(karma({
      configFile: 'karma.conf.js',
      action: 'run'
    }))

karma.conf.js

module.exports = function (config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    frameworks: ['mocha', 'chai'],

    // list of files / patterns to load in the browser
    files: [
      'node_modules/jquery/dist/jquery.js',
      'jquery.my-lib.js',
      'test/*.js'
    ],

How to pass a regular expression in a karma configuration file?

Hi,

I am using webpack. My webpack configuration requires some regular expressions.
I cannot use regexes because karma config is stringified in gulp-karma and than all regular expressions are converted into empty objects.

Is there any way to pass a regular expression in karma configuration using gulp-karma?

Files order is not preserved

When you pass your testfiles via pipe the order is not preserved.
Example, 'file2' can end up in front of files of 'dir1'.

gulp.src(['file1.js', 'dir1/**/*.js', 'file2.js'])
    .pipe(karma({
        configFile: 'myKarmaConfigFile.conf.js'
    }));

This causes issues in situations where you rely on the order of execution.

Unhandled exception when test fails

When I have a test that fails I get the following exception:

/Users/pete/work/projects/console/node_modules/gulp-karma/index.js:56
        stream.emit('error', new gutil.PluginError('gulp-karma', 'karma exited
                             ^
TypeError: undefined is not a function
  at done (/Users/pete/work/projects/console/node_modules/gulp-karma/index.js:56:30)
  at ChildProcess.<anonymous> (/Users/pete/kinvey/projects/console/node_modules/gulp-karma/index.js:82:7)
  at ChildProcess.EventEmitter.emit (events.js:98:17)
  at Process.ChildProcess._handle.onexit (child_process.js:797:12)

Which breaks the pipe.

npm install 404s

Trying to upgrade to fix issue #4

Installation gets the following error:

npm ERR! fetch failed https://registry.npmjs.org/gulp-karma/-/gulp-karma-0.0.2.tgz
npm ERR! Error: 404 Not Found
npm ERR!     at WriteStream.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:57:12)
npm ERR!     at WriteStream.EventEmitter.emit (events.js:117:20)
npm ERR!     at fs.js:1596:14
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:103:5
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Darwin 12.5.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "gulp-karma"
npm ERR! cwd /Users/kmiller/newrelic/rpm_site
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14

add karma as dependency

I think this plugin should specify karma as dependency so that people know it depends on karma.

include file not being included

My karma.conf.js contains this:

        // list of files / patterns to load in the browser
        files: [
            {pattern: 'node_modules/should/should.min.js', include: true},
            'tests/**/*.spec.js'
        ],

It works fine when I run it directly through karma, but when I run it through Gulp, I'm getting the following error:

[gulp] Starting Karma server...
INFO [karma]: Karma v0.12.3 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [launcher]: Starting browser Firefox
INFO [Chrome 33.0.1750 (Mac OS X 10.9.2)]: Connected on socket mlbZmue-cZ-ZzjWbNby2 with id 54290239
Chrome 33.0.1750 (Mac OS X 10.9.2) API meta should return with root FAILED   
        TypeError: Cannot read property 'be' of undefined
            at Context.<anonymous> (/Applications/XAMPP/xamppfiles/htdocs/dirname/tests/api.spec.js:8:16)
            at callFn (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4338:21)
            at Test.Runnable.run (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4331:7)
            at Runner.runTest (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4728:10)
            at /Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4806:12
            at next (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4653:14)
            at /Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4663:7
            at next (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4601:23)
            at /Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4630:5
            at timeslice (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:5761:27)
Chrome 33.0.1750 (Mac OS X 10.9.2): Executed 1 of 1 (1 FAILED) ERROR (0.021 secs / 0.001 secs)
Firefox 26.0.0 (Mac OS X 10.9) API meta should return with root FAILED                          
        "/".should is undefined                                          
        @/Applications/XAMPP/xamppfiles/htdocs/dirname/tests/api.spec.js:8
        callFn@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4338
        Runnable.prototype.run@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4331
        Runner.prototype.runTest@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4728
        next/<@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4806
        next@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4653
        next/<@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4663
        next@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4601
        Runner.prototype.hook/<@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:4630
        timeslice@/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/mocha/mocha.js:5761

Chrome 33.0.1750 (Mac OS X 10.9.2): Executed 1 of 1 (1 FAILED) ERROR (0.021 secs / 0.001 secs)
Firefox 26.0.0 (Mac OS X 10.9): Executed 1 of 1 (1 FAILED) ERROR (0.006 secs / 0.001 secs)

/Applications/XAMPP/xamppfiles/htdocs/dirname/gulpfile.js:94
                        throw err;
                              ^
[gulp] Error in plugin 'gulp-karma': karma exited with code 1
    at done (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/gulp-karma/index.js:56:30)
    at ChildProcess.<anonymous> (/Applications/XAMPP/xamppfiles/htdocs/dirname/node_modules/gulp-karma/index.js:82:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:789:12)

Here is my test file:

'use strict';

/* global describe, it */

describe('API', function () {
    describe('meta', function () {
        it('should return with root', function () {
            ('/').should.be.exactly('/');
        });
    });
});

Here is my gulp task:

gulp.task('test', function() {
    // Be sure to return the stream
    return gulp.src('tests/**/*.spec.js')
        .pipe(plugins.karma({
            configFile: 'karma.conf.js',
            action: 'run'
        }))
        .on('error', function (err) {
            throw err;
        });
});

To me, it looks like should.js isn't being included at all. I don't know how to debug it, though.

Error: No provider for "framework:jasmine"

i get the following error:

./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
    at error (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at ./node_modules/gulp-karma/node_modules/karma/lib/server.js:29:14
    at Array.forEach (native)
    at start (./node_modules/gulp-karma/node_modules/karma/lib/server.js:28:21)
    at invoke (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (./node_modules/gulp-karma/node_modules/karma/lib/server.js:272:12)
    at Object.<anonymous> (./node_modules/gulp-karma/lib/background.js:3:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

If i start karma from console it works as expected (./node_modules/.bin/karma run).

PhantomJS Parsing Errors when Watching CoffeeScript Specs

I have gulp watching coffee spec files like this

filePath = {
unit:   { 
            src: [
              'bower_components/angular/angular.js',
              'bower_components/angular-*/angular-*.js',
              'app/modules/**/*.coffee',
              'app/*.coffee'
            ]
          }

gulp.task('watch-unit', function() {
  gulp.src(filePath.unit.src)
    .pipe(karma({
      configFile: './spec/config/karma-unit.conf.js',
      action: 'watch'
    }));
});
}

Now, every time I save a spec file, the tests are run, but the following errors written to the log on each run (see below). Please note, that these errors only show up when I am watching CoffeeScript specs. They neither show up when I run specs manually, nor when I replace coffee specs with complied javascript. Not sure if this is an issue with gulp-karma, karma-coffee-preprocessor plugin or something else. Any guidance is appreciated. Hate seeing red errors when specs are passing.

PhantomJS 1.9.7 (Mac OS X) ERROR
  SyntaxError: Parse error
  at /Users/dmoore/projects/hotilinet/hotilinet-web/bower_components/angular/angular.js:4208

PhantomJS 1.9.7 (Mac OS X) ERROR
  TypeError: 'undefined' is not an object (evaluating 'angular.module')
  at /Users/dmoore/projects/hotilinet/hotilinet-web/bower_components/angular-animate/angular-animate.js:242

PhantomJS 1.9.7 (Mac OS X) ERROR
  TypeError: 'undefined' is not an object (evaluating 'g.module')
  at /Users/dmoore/projects/hotilinet/hotilinet-web/bower_components/angular-animate/angular-animate.min.js:6

PhantomJS 1.9.7 (Mac OS X) ERROR
  TypeError: 'undefined' is not an object (evaluating 'angular.mock = {}')
  at /Users/dmoore/projects/hotilinet/hotilinet-web/bower_components/angular-mocks/angular-mocks.js:17

PhantomJS 1.9.7 (Mac OS X) ERROR
  TypeError: 'undefined' is not an object (evaluating 'angular.$$minErr')
  at /Users/dmoore/projects/hotilinet/hotilinet-web/bower_components/angular-resource/angular-resource.js:8

PhantomJS 1.9.7 (Mac OS X) ERROR
  TypeError: 'undefined' is not an object (evaluating 'a.$$minErr')
  at /Users/dmoore/projects/hotilinet/hotilinet-web/bower_components/angular-resource/angular-resource.min.js:6

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/app.js:2

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/states.js:2

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/modules/home/home.js:2

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/modules/login/login.js:2

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/modules/shared/services/auth.js:1

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/modules/shared/services/facebook-login.js:1

PhantomJS 1.9.7 (Mac OS X) ERROR
  ReferenceError: Can't find variable: angular
  at /Users/dmoore/projects/hotilinet/hotilinet-web/app/modules/shared/services/session.js:1

INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket L9VX0thO81Rf8Rwyb5uC with id 43943167
PhantomJS 1.9.7 (Mac OS X): Executed 2 of 3 (skipped 1) SUCCESS (0.003 secs / 0.016 secs)

Formally deprecate gulp-karma

Creating separate issue to track progress on deprecating this module in favor of running karma directly.

https://docs.npmjs.com/cli/deprecate

From the karma folks:

var gulp = require('gulp');
var Server = require('karma').Server;

/**
 * Run test once and exit
 */
gulp.task('test', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, done).start();
});

WARN `start` method is deprecated since 0.13

Maybe this is not gulp-karma problem but always get this warning when starting tests with gulp. Seems gulp-karma is using old start method for karma?

Here's my gulpfile.js:

var karma = require('gulp-karma');

...

var testFiles = [
'./src/js/.js',
'./spec/js/
.spec.js'
];

gulp.task('test', function() {
console.log("It's testing...".random)
return gulp.src(testFiles)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});

And full warning:

[11:01:35] Starting Karma server...
WARN start method is deprecated since 0.13. It will be removed in 0.14. Please use
server = new Server(config, [done])
server.start()
instead.

New to gulp, npm, karma and testing in general so could well be me!

Use a gulp watch

Hi. I know you have just depended on using karma's builtin file-watching with this plugin thus far to keep it easy. I'm interested in getting it to use one of the gulp watch only plugins though. Either the built-in gulp.watch or the gulp-watch plugin.

A few reasons why I think this is important:

  • Gulp's philosophy is using plugins that do one thing and do it really well.
  • No need to have more than one watcher which I think would be good for performance.
  • Grunt already does this.

I haven't even looked in to what this would take. In any case, would you be open to it?

Advantages of this plugin?

What are the advantages of this plugin over using Karma directly?
Also, doesn't this plugin violate the first rule of the Gulp plugin guidelines?

Your plugin should not do something that can be done easily with an existing node module

  • For example: deleting a folder does not need to be a gulp plugin. Use a module like del within a task instead.
  • Wrapping every possible thing just for the sake of wrapping it will pollute the ecosystem with low quality plugins that don't make sense within the gulp paradigm.
  • gulp plugins are for file-based operations! If you find yourself shoehorning a complex process into streams just make a normal node module instead.
  • A good example of a gulp plugin would be something like gulp-coffee. The coffee-script module does not work with Vinyl out of the box, so we wrap it to add this functionality and abstract away pain points to make it work well within gulp.

I kind of remember that there where some issues with using Karma directly, and I think that must be why I have been using this plugin. But since these issues are now fixed, is there still a reason for this plugin to exists?

WARN [reporter]: Can not load "coverage"

I get the following warning:

WARN [reporter]: Can not load "coverage", it is not registered!
  Perhaps you are missing some plugin?

I have the following block in my karma.conf.js file:

preprocessors: {
  '**/build/*.js': 'coverage'
},
reporters: ['progress', 'coverage'],

In my package.json i have the dependency "karma-coverage": "~0.1.4" which solves the warning if i run karma directly, but does seem to have no effect on gulp-karma.

Issues with the canary versions of karma

I'm having issues running gulp-karma w/ the packaged version of Karma 0.11.9.

Perhaps gulp-karma can have two release versions, an even series - tracking the stable version of Karma, and an odd series, tracking the canary versions of Karma?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.