vendredi 22 février 2019

manage mocha project with karma

I try to launch test mocha browser (which run correctly with index.html into my browser) with Karma.

But Karma tell me that cannot find './lib/mocha' (into mocha.js) and all others library necessary.

  1. I already installed those package : karma-mocha and karma-browserify
  2. my config karma file has browserify and mocha on frameworks (in this order)
  3. my pattern file karma is : 'test/browser/*.js'
  4. My preprocessors karma is : 'test/browser/*.js': ['browserify']

The mocha.js file created dynamically by mocha init command into my test/browser directory and it write a require('./lib/mocha') which doesn't exist in my browser directory.

It is not a browserify works to resolve this require ?

Peharps I need to rewrite mocha.js ?

my karma.conf.js file :

    // Karma configuration
// Generated on Fri Feb 22 2019 16:55:47 GMT+0100 (GMT+01:00)

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: ['browserify', 'mocha', 'jquery-3.3.1'],


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


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


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'test/browser/*.js': ['browserify']
    },

    // browserify: {
    //   debug: true,
    //   transform: [ 'brfs' ]
    // },


    // 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
  })
}

Aucun commentaire:

Enregistrer un commentaire