mercredi 25 novembre 2015

karma.js not returning any results following basic "karma init" setup

I'm following the "Introduction to Karma" tutorial by egghead.io found here http://ift.tt/1m3cFPa , and followed the following (on Windows):

> npm install --g karma-cli
> npm install karma karma-jasmine karma-chrome-launcher --save-dev
karma init

Followed default configuration on initial karma configuration, and then created a test.spec.js file in current folder with the following code:

describe('Test', function() {
    it('It should be true', function() { expect(true).toBe(true); });
});

Lastly, I added such file to the karma.conf.js file like so:

files: [
      'test.spec.js'
    ],

However, upon running

karma start karma.conf.js

I get nothing but a:

25 11 2015 16:35:35.551:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/

Why don't any tests execute? Also, opening that localhost url (it's the same as setting browsers to ['chrome'] in karma.conf.js) just shows that karma is running and that chrome is idle, but no test results are returned.

edit: Added karma.conf.js

// Karma configuration
// Generated on Wed Nov 25 2015 16:19:43 GMT-0600 (Central Standard Time (Mexico))

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: http://ift.tt/1ft83uu
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      '*spec.js'
    ],


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


    // preprocess matching files before serving them to the browser
    // available preprocessors: http://ift.tt/1gyw6MG
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: http://ift.tt/1ft83KQ
    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: false,


    // start these browsers
    // available browser launchers: http://ift.tt/1ft83KU
    browsers: [],


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

    // Concurrency level
    // how many browser should be started simultanous
    concurrency: Infinity
  })
}

edit2: Added package.json

{
  "name": "karma-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "karma start karma.conf.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "jasmine-core": "^2.3.4",
    "karma": "^0.13.15",
    "karma-chrome-launcher": "^0.2.1",
    "karma-jasmine": "^0.3.6"
  }
}

edit3: Found a solution. Check my own reply

Aucun commentaire:

Enregistrer un commentaire