Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Executed 0 of 0 ERROR" in the console #753

Closed
marcobarbosa opened this issue Sep 23, 2013 · 28 comments
Closed

Getting "Executed 0 of 0 ERROR" in the console #753

marcobarbosa opened this issue Sep 23, 2013 · 28 comments
Labels

Comments

@marcobarbosa
Copy link

Hi all,

I'm trying to use karma with jasmine-flight and require.js.

I have no tests in place, just want to get a normal "0 of 0 SUCESS" before getting started.

However this is ERROR is shown in my console:

INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 29.0.1547 (Mac OS X 10.8.5)]: Connected on socket YRMSwebi_lNtEYDnL0rk
Chrome 29.0.1547 (Mac OS X 10.8.5): Executed 0 of 0 ERROR (0.171 secs / 0 secs)

I have found similar issues but related to "Angular" not "Flight".

This is my karma.conf:

// Karma configuration
// Generated on Thu Sep 19 2013 16:31:19 GMT+0200 (CEST)

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

    // base path, that will be used to resolve files and exclude
    basePath: '',

    // frameworks to use
    frameworks: ['requirejs', 'jasmine'],

    // list of files / patterns to load in the browser
    files: [
        '../bower_components/jasmine-flight/lib/jasmine-flight.js',
        '../bower_components/jasmine-jquery/lib/jasmine-jquery.js',

        {pattern: '*.js', included: false},
        {pattern: 'mixins/*.js', included: false},
        {pattern: 'data/*.js', included: false},
        {pattern: 'pages/*.js', included: false},
        {pattern: 'ui/**/*.js', included: false},
        {pattern: 'tests/spec/**/*.spec.js', included: false},

        // Entry point for karma.
        'tests/test-main.js'
    ],

    // list of files to exclude
    exclude: [
        '../bower_components/flight/lib/standalone/*.js'
    ],

    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['dots'],


    // web server port
    port: 9876,

    // 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,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],


    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 5000,


    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false,

    // report which specs are slower than 500ms
    // CLI --report-slower-than 500
    reportSlowerThan: 500,

    plugins: [
            'karma-jasmine',
            'karma-requirejs',
            'karma-chrome-launcher',
            'karma-safari-launcher'
        ]
  });
};

Is this a bug or am I doing something wrong?

@bolasblack
Copy link

I've also got the same error.

result

INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 29.0.1547 (Mac OS X 10.8.5)]: Connected on socket dAmNUJiZMZvLa53AfORr
LOG: 'spec run'
Chrome 29.0.1547 (Mac OS X 10.8.5): Executed 0 of 0 ERROR (0.755 secs / 0 secs)

karma.conf.coffee

module.exports = (config) ->
  config.set

    plugins: [
      'karma-chai'
      'karma-mocha'
      'karma-chrome-launcher'
      'karma-coffee-preprocessor'
    ]

    # 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: [
      'public/js/vendor.js'
      'bower_components/angular-mocks/angular-mocks.js'
      'app/resources/**/*.coffee'
      'test/unit/**/*.spec.*'
    ]

    # list of files to exclude
    exclude: []

    preprocessors: {
      'app/resources/**/*.coffee': ['coffee']
      'test/unit/**/*.coffee': ['coffee']
    }

    # use dots reporter, as travis terminal does not support escaping sequences
    # possible values: 'dots', 'progress'
    # CLI --reporters progress
    reporters: ['progress']

    # web server port
    # CLI --port 9876
    port: 9876

    # enable / disable colors in the output (reporters and logs)
    # CLI --colors --no-colors
    colors: true

    # level of logging
    # possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    # CLI --log-level debug
    logLevel: config.LOG_INFO

    # enable / disable watching file and executing tests whenever any file changes
    # CLI --auto-watch --no-auto-watch
    autoWatch: true

    # Start these browsers, currently available:
    # - Chrome
    # - ChromeCanary
    # - Firefox
    # - Opera
    # - Safari (only Mac)
    # - PhantomJS
    # - IE (only Windows)
    # CLI --browsers Chrome,Firefox,Safari
    browsers: ['Chrome']

    # If browser does not capture in given timeout [ms], kill it
    # CLI --capture-timeout 5000
    captureTimeout: 20000

    # Auto run tests on start (when browsers are captured) and exit
    # CLI --single-run --no-single-run
    singleRun: false

    # report which specs are slower than 500ms
    # CLI --report-slower-than 500
    reportSlowerThan: 500

resources.spec.coffee

'use strict'

console.log 'spec run' # it's ok

describe "services", ->

  it "should error", ->
    console.log 'it should error' # not print
    'a'.should.equal 1

@bolasblack
Copy link

I resolved the error when I remove angular-scenario from vendor.js file.

Thanks stackoverflow: http://stackoverflow.com/questions/18366837/karma-not-running-tests

@marcobarbosa is it can help you?

@marcobarbosa
Copy link
Author

@bolasblack No, since I'm not using Angular. Thanks anyway! :)

@dignifiedquire
Copy link
Member

@marcobarbosa Do you have a github project I could look at? Or just a simple example that reproduces what you are seeing.

@marcobarbosa
Copy link
Author

Sorry it's actually private so I can't share :(

I have updated the karma.conf above but just some paths - shouldn't interfere.

@dignifiedquire
Copy link
Member

@marcobarbosa This looks like a problem loading the tests. Can you share the relevant parts of your test-main.js?

@vojtajina
Copy link
Contributor

@marcobarbosa it's hard to help with this without seeing your files. It's more likely you are not including the test files or they are not executed. What is your test-main.js look like ?

@marcobarbosa
Copy link
Author

Hi guys,

Sorry about this. I don't have access to the files (private) so I can't really paste them.

I know this is how my test-main.js was looking like then:

'use strict';

var tests = Object.keys(window.__karma__.files).filter(function (file) {
  return (/\.spec\.js$/.test(file));
});

requirejs.config({
  // Karma serves files from '/base'
  baseUrl: '/base',

  paths: {
    // required! don't remove this line
    flight: 'app/bower_components/flight',
    // ----------------------------------
    events: 'app/scripts/events',
    utils: 'app/scripts/utils',

    // Templating
    mustache: 'app/bower_components/mustache/mustache'
  },

  map: {
      '*': {
          'flight/component': 'app/bower_components/flight/lib/component',
          'flight/compose': 'app/bower_components/flight/lib/compose',
          'flight/lib/registry': 'app/bower_components/flight/lib/registry'
      },
  },

  shim: {
    'app/bower_components/flight/lib/index': {
      deps: ['jquery', 'es5shim', 'es5sham']
    }
  },

  // ask Require.js to load these files (all our tests)
  deps: tests,

  // start test run, once Require.js is done
  callback: window.__karma__.start
});

// jasmine.getFixtures().fixturesPath = 'base/test/fixtures';

@marcobarbosa
Copy link
Author

Maybe this issue should be closed?

@vojtajina
Copy link
Contributor

@marcobarbosa Did you figure this out?

Check console.log(tests); in your test-main.js, to make sure the tests are loaded.

@mikew
Copy link

mikew commented Dec 30, 2013

I too am seeing this error. Not sure if it's because I'm using brunch and the tests are all wrapped in requires, but everything works fine and dandy loading the mocha test page in the browser, and running it with mocha-phantomjs.

https://github.com/mikew/brunch-flask

Given that I am using brunch, this isn't a huge deal, though I do like the auto-launching of the browsers and the console output.

@mikew
Copy link

mikew commented Dec 30, 2013

Ah, trying out test'em lead me to the solution.

  • Remove mocha.css, mocha.js, chai.js from test/vendor/
  • Install karma-chai
  • Change frameworks to ['mocha', 'chai']

@vojtajina
Copy link
Contributor

Yeah, you need the mocha framework because of the adapter (you could load mocha itself from your project as before and that would work.

Anyway, now Karma complains that you are missing an adapter, which would at least make it easier to debug. Closing.

@ttencate
Copy link

FWIW, I ran into this anonymous ERROR problem as well. It went away when I deleted my node_modules directory and re-ran npm install.

Since I'd been hacking around in modules' source code, I don't think this would happen during normal karma operation.

@andrerpena
Copy link

In case this helps anyone, I ran into this problem because my main test file has 2 describe but no it.

It was like this:

describe('Something abstract', function() {
    describe('Something specific', function() {
    });
});

And when I made it like this, it worked:

describe('Something abstract', function() {
    describe('Something specific', function() {
        it('Something', function() {
            assert.equal(1, 1);
        });
    });
});

@axelson
Copy link

axelson commented Jan 19, 2016

For those still coming across this from searches the default behavior appears to have possibly switched so that having no tests causes an error: #1690

@DevFacts
Copy link

Hi guys!
Getting "Executed 0 of 0 ERROR" in the console (FIXED)

My config file name is (test.conf.js)

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

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


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'../www/lib/angular/angular.js',
'../www/js/*.js',
'../www/lib/angular-mocks/angular-mocks.js',
'**/*.js'
],


// list of files to exclude
exclude: [
],


// 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'],


// web server port
port: 9876,


// 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,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


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


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

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity

})
}
==========================Code====END===============================
Explanation:-

files: [
'../www/lib/angular/angular.js',
'../www/js/.js',
'../www/lib/angular-mocks/angular-mocks.js',
'__/
.js'
]

In this part, I always ignore. But here was the problem
My old code [ 'test//*.js' ] and new is [ '/*.js' ]

My project directory

Project22
-js
-css
-test (test folder)
-test.conf.js
-templates

I think it should work fine for you.

@dummdidumm
Copy link

I got this error while using Chrome (or ChromeHeadless) as browser + using typescript. This solution fixed it for me: angular/angular-cli#2125 (comment)

@pmandapuram
Copy link

pmandapuram commented Dec 13, 2017

Hi ,
I am written jasmine test cases to a method that get all attributes which are available in database
is it possible to test from jasmine test suite
and i am getting 0 specs and 0 failures when i am running the tests
Please help me to sort out this problem

image

@johnjbarton
Copy link
Contributor

  1. If you are using asynchronous code (promises), verify that you return a promise chain or call done().
  2. Open the DEBUG window and use devtools to examine the test.

@pmandapuram
Copy link

thanks Johnjbarton

@Drumstix42
Copy link

Anyone coming across this thread years later, as I did. I discovered there is a boolean you can set in the config object, failOnEmptyTestSuite
This let me setup a configuration without needing to define any test cases.

See: http://karma-runner.github.io/2.0/config/configuration-file.html

@aj-r
Copy link

aj-r commented Jun 20, 2018

Got this error when testing with typescript. The reason is because karma does not host typescript files by default. The solution was to add this to my karma config:

    mime: {
      "text/x-typescript": ["ts", "tsx"],
    },

@yogeshwar1996
Copy link

Thanks @aj-r adding mime property to karma.conf.js helped me. Now my tests are executing

@rupeshtiwari
Copy link

In my case it was below line that I was missing bootstrap angular.

const app = bootstrapModule(getMockSettings());
(angular as any).lowercase = text => text.toLowerCase();
angular.bootstrap(document, [app ]);

@collinkrawll
Copy link

In my case, I was actually getting "Executed 0 of N ERROR". Simple tests would show in N but would never actually be executed. I removed each of my scripts and eventually narrowed it down to a jQuery(document).ready(... function that was throwing an exception that was being swallowed. I guess the tests were being registered but never got to execute (and the exception was being swallowed).

@Kendsar
Copy link

Kendsar commented Mar 28, 2019

In my case I was trying to run

ng test

While I'am not running

npm start

And that's will not work and will show 0 specs, 0 failures ,of course.

@cluzier
Copy link

cluzier commented May 17, 2019

I resolved the error when I remove angular-scenario from vendor.js file.

Thanks stackoverflow: http://stackoverflow.com/questions/18366837/karma-not-running-tests

@marcobarbosa is it can help you?

can anyone else confirmed this worked for them before I do it myself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests