karma-mocha

chai is not defined in Karma-mocha

南笙酒味 提交于 2019-12-05 08:24:52
I am running my test cases succesfully using mocha-phantomjs configurations. Now I am running these test using Karma launcher. But I get the issue Chai is not defined . Here is my configuration file. module.exports = function(config) { config.set({ client: { mocha: { ui: 'tdd' } }, basePath: '', frameworks: ['mocha'], files: [ 'web/js/*.js', 'test/lib/*.js', 'node_modules/chai/chai.js' //added this on suggestion of the answer in stackoverflow ], exclude: [ ], preprocessors: { }, reporters: ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Firefox']

Karma can't load webpack

纵然是瞬间 提交于 2019-12-05 07:54:37
I'm getting this error; 16 07 2015 13:03:52.741:WARN [preprocess]: Can not load "webpack"! Error: Can not resolve circular dependency! (Resolving: preprocessor:webpack -> webpackPlugin -> preprocessor:webpack) My karma.conf looks like; var webpack = require('webpack'); module.exports = function (config) { config.set({ browsers: [ 'Chrome' ], //run in Chrome singleRun: true, //just run once by default frameworks: [ 'mocha' ], //use the mocha test framework files: [ 'tests.webpack.js' //just load this file ], preprocessors: { 'tests.webpack.js': [ 'webpack', 'sourcemap' ] //preprocess with

Mocha unit tests running with Karma - done() is not defined

六眼飞鱼酱① 提交于 2019-12-05 02:04:33
I'm trying to get tests written with Mocha to work running Karma, and they sort of work, but I cannot use the done() method to implement async tests, which essentially makes the tools useless to me. What am I missing? karma.conf.js module.exports = function(config) { config.set({ basePath: '../..', frameworks: ['mocha', 'requirejs', 'qunit'], client: { mocha: { ui: 'bdd' } }, files: [ {pattern: 'libs/**/*.js', included: false}, {pattern: 'src/**/*.js', included: false}, {pattern: 'tests/mocha/mocha.js', included: false}, {pattern: 'tests/should/should.js', included: false}, {pattern: 'tests/**

Karma, PhantomJS and es6 Promises

那年仲夏 提交于 2019-12-03 10:31:53
问题 I am writing a JavaScript library that uses the new es6 promises. I can test the library in Firefox because promises are defined. However, when I try to test my code with Karma and PhantomJS, I get the error Can't find variable: Promise. . I am guessing this is because the PhantomJS browser doesn't support es6 promises yet. How can I configure Karma to bring in the polyfill for promises? 回答1: You can pull in the Babel polyfill by simply installing Babel Polyfill: npm install --save-dev babel

Explain karma unit test times

落花浮王杯 提交于 2019-12-02 01:08:24
I've been searching the web for this for two days and I found nothing. Maybe I'm looking in the wrong way — I don't know... So here it is: what are the times on my console when running a Karma+Jasmine+phantomJs unit test? ... Executed 1 of 1 SUCCESS (0.878 secs / 0.112 secs) First, I though that the second time is the total unit test time (for example, when running multiple tasks), however, sometimes the first time gets to be 'bigger', sometimes not... Anyone? total time / net time net time = only test execution (in the browser) total time = how long it took since Karma noticed the file change

TypeError: expect(…).to.be is not a function

半世苍凉 提交于 2019-11-30 05:57:37
I am configuring my Karma amd mocha framework with grunt in my project. When I am running karma start I am getting below-mentioned error. I am getting this error in my console while running command : Karma start TypeError: expect(...).to.be is not a function My Karma.confjs // Karma configuration // Generated on Fri Nov 27 2015 11:48:47 GMT+0530 (India Standard Time) 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

TypeError: expect(…).to.be is not a function

怎甘沉沦 提交于 2019-11-29 05:17:51
问题 I am configuring my Karma amd mocha framework with grunt in my project. When I am running karma start I am getting below-mentioned error. I am getting this error in my console while running command : Karma start TypeError: expect(...).to.be is not a function My Karma.confjs // Karma configuration // Generated on Fri Nov 27 2015 11:48:47 GMT+0530 (India Standard Time) module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude)