Questions tagged [karma-mocha]

karma-mocha is a Karma plugin. Adapter for Mocha testing framework.

karma-mocha is A Karma plugin. Adapter for Mocha testing framework.

325 questions
3
votes
1 answer

webpack dllplugin how to use with karma?

I am trying to use a DLLReferencePlugin in my karma tests and I'm not entirely sure how to have it work. I've placed vendors.js and vendors-manifest.json in src/static/ The dll was generated with libraryTarget=var and it works in my dev and…
Terence Chow
  • 10,755
  • 24
  • 78
  • 141
3
votes
1 answer

Testing connected react component that needs params

I'm trying to test a connected react component that needs a props.params.id to call action creators. When I try to test that the component is connected to the store I get "Uncaught TypeError: Cannot read property 'id' of undefined" ReactDOM.render( …
kasho
  • 508
  • 4
  • 10
3
votes
1 answer

Karma passes test when promise is rejected during assertion

If the promise itself is rejected as in the 'does fail' test, then the test fails as I would expect. If an assertion fails/error is thrown/promise is rejected in the "then" of the promise I get logging saying ERROR: 'Unhandled promise rejection'…
Ryan Swanson
  • 33
  • 1
  • 5
3
votes
0 answers

Karma Coverage for React JSX Files is Corrupted

I'm running test coverage over my .js and .jsx files using karma, mocha, and isparta for ES6 code coverage. For some reason the coverage report over .jsx files is corrupted. See the following image: The report looks the same for all of the .jsx…
Ziv Levy
  • 1,904
  • 2
  • 21
  • 32
3
votes
1 answer

Karma gives me a __karma__.start adapter error without any other error

I don't know how to fix this issue. I get no errors other than the one above. Here are my config files: ./webpack.config.js var path = require('path'); var webpack = require('webpack'); module.exports = { entry: './src/app/app.jsx', output: {…
Gasim
  • 7,615
  • 14
  • 64
  • 131
3
votes
0 answers

Webpack Externals with mocha/karma

I'm trying to setup testing environment with mocha and karma on top of that but I keep getting "Variable not found" from Karma when trying to run test where I use component that has the dependancy on "externals". import RootComponent from…
ArniReynir
  • 849
  • 3
  • 12
  • 29
3
votes
3 answers

webpackJsonp not defined using karma-webpack?

I am building a boilerplate with webpack and karma with mocha. This is the configuration I am using for karma-webpack. I am new to webpack. var path = require('path'); var webpack = require('webpack'); var entries = { "app":…
juan garcia
  • 1,326
  • 2
  • 23
  • 56
3
votes
2 answers

cannot use beforeEach with the inject function

This is from the karma.conf.js file: module.exports = function (config) { config.set({ frameworks: ['mocha', 'chai'], files: [ 'bower_components/angular/angular.js', 'bower_components/angular-mocks/angular-mocks.js', …
commonUser
  • 599
  • 1
  • 6
  • 17
3
votes
0 answers

Error: [$injector:modulerr] on Karma

I am a newbie to testing with Karma and Mocha. I want to do a unit test on the following controller: 'use strict'; // common functionality angular.module('app').controller('CommonCtrl', ['$scope', 'appConfig', function ($scope, appConfig) { …
Marcel
  • 1,537
  • 5
  • 19
  • 38
3
votes
1 answer

How to Mock $location.path in Angular Unit Test (Mocha)

I'm using Karma, Mocha, Sinon and Chai for my Angular unit tests and I'm trying to figure out how to mock a redirect I'm doing in my controller with $location. My controller does the following redirect: $location.path('home'); I want to try and…
realph
  • 4,481
  • 13
  • 49
  • 104
3
votes
1 answer

Setting up Karma with Angular, Babel (ES6), Webpack and Mocha

I'm trying to setup Karma on a project with Angular. The error I'm currently receiving is: Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you…
Landon Cline
  • 31
  • 1
  • 4
3
votes
0 answers

AngularJS inject $timeout to a link?

So here is what my issue is: i have a directive: autocompleteDirective.$inject = ['$timeout']; function autocompleteDirective($timeout) { return { restrict: 'E', scope: { searchParam: '=ngModel', suggestions:…
Nate
  • 1,630
  • 2
  • 24
  • 41
3
votes
1 answer

Testing a filter used within a controller function

I have the following test case: it('should return id if the post is successful',function(){ var result = { id : "123" }; ctrl.saveCallback(result); expect(ctrl.method.id).to.equal("123"); }); Where…
km1882
  • 740
  • 5
  • 22
3
votes
1 answer

How to test directive in link phase?

Here is some Javascript that makes a call to jqLite's trigger inside the link function of an AngularJS directive. angular. module('myApp'). directive('myDirective', function($timeout) { return { link: function(scope) { …
Trindaz
  • 17,029
  • 21
  • 82
  • 111
3
votes
1 answer

Unit-testing multiple use cases with Karma & Mocha.js

I'm fairly new to testing, so this question is about best-practices and how this test ought to be written. I'm using Karma with Mocha and Chai to test an Angular.js app. I'm currently testing a function that counts the number of ways to arrange a…
Deimyts
  • 374
  • 2
  • 3
  • 13