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
2
votes
0 answers

Why doesn't my karma support for...of statement?

I have setup karma as my unit test framework. But it doesn't compile below code: let {btnData} = this.props let buttons = [] for (let btn of btnData) { btn = {...btnCategories[btn.type], ...btn} buttons.push(btn) } I got below error on the line…
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
2
votes
1 answer

Karma: node-oracledb is not imported well

I have node-oracledb "oracledb": "1.11.0" running well in my project, but don't work well in my tests. After $ npm test command: 15 11 2016 23:29:56.074:ERROR [framework.browserify]: Error: Cannot find module '../build/Release/oracledb' from…
Aral Roca
  • 5,442
  • 8
  • 47
  • 78
2
votes
1 answer

"TypeError: expect(...).to.have.been.calledWith is not a function" With Karma

I have the following Karma Conf... var webpackConfig = require('./webpack.config.js'); webpackConfig.entry = {}; webpackConfig.plugins = []; var globFlat = require('glob-flat'); // TODO: These are redundant with the webpack plugin... var appFiles =…
Jackie
  • 21,969
  • 32
  • 147
  • 289
2
votes
1 answer

Meteor & Mocha Chai : test insert function

I'm trying to test my insert function but It fail with UserAccount: Error: Cannot read property 'username' of undefined I don't know how to make the test pass for inserting a post, here is my method: Meteor.methods({ 'posts.insert'(title,…
myput
  • 422
  • 1
  • 10
  • 26
2
votes
1 answer

Angular2 testing service -- undefined service

Hi I am trying to write unit tests for my service following this procedure: https://developers.livechatinc.com/blog/testing-angular-2-apps-dependency-injection-and-components/ but I keep getting an error. Here is the service test import…
es3735746
  • 841
  • 3
  • 16
  • 40
2
votes
2 answers

How can window object properties be mocked in a karma/mocha test suite?

I'm using karma and mocha along with React's TestUtils to test a React application. One of the components that I'm testing imports a module with the following export: export const OPTIONS = window.__OPTIONS__; In my test, I am rendering the…
Matt Thomas
  • 121
  • 1
  • 3
2
votes
0 answers

Can't find nodes with enzyme and css-modules when using karma-webpack

I've been using css-modules with mocha, enzyme and css-modules-require-hook without any problems. Foo.js import React from 'react'; import styles from './Foo.css'; const Foo = () =>
Foo component
; export default…
qmmr
  • 502
  • 1
  • 5
  • 17
2
votes
2 answers

Angularjs Mocha test $q promises without $rootScope.$apply

I have this service: angular.module('domeeApp') .factory('streamWidget', streamWidgetFactory); function streamWidgetFactory($q) { return { loadContent: function() { return $q(function(resolve,…
pietrovismara
  • 6,102
  • 5
  • 33
  • 45
2
votes
1 answer

nwjs and karma-mocha not playing nice

I am having issues testing my NW.js app using Karma. Tests that used to work now don't after updating ??? (I'm not sure which update killed me) START: 13 07 2016 08:33:30.517:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/ 13 07…
ed4becky
  • 1,488
  • 1
  • 17
  • 54
2
votes
1 answer

Failing to run tests using Karma

I am setting up Karma to simplify unit tests in a legacy project. The problem is, I am getting an error You need to include some adapter that implements __karma__.start method!. As I have found, this is a very non-specific error, so I am at a loss…
azangru
  • 2,644
  • 5
  • 34
  • 55
2
votes
4 answers

Jasmine angular unit test 'Cannot read 'property' of undefined

I have just started learning angular unit testing. However, this test on a function with http call fails. I have pin pointed the problem but however I am not being able to fix it. I know it's some simple issue Controller //Get data from…
2
votes
0 answers

How do I un-register a decorator in AngularJS?

I ran into a test case where I want to register an AngularJS decorator in the context of the unit test. The decorator helps me mock the interaction between a parent component and its child component. I register the decorator in my beforeEach, and it…
RMorrisey
  • 7,637
  • 9
  • 53
  • 71
2
votes
1 answer

Leaflet plugin not available in AngularJS controller during unit tests

I'm using Karma + Mocha to test a controller in Angular. The code below is a simplified example of the controller & test spec. L.Control.Locate is a LeafletJS plugin. The problem During a test run L.Control.Locate should exist when the controller…
kentr
  • 969
  • 1
  • 11
  • 21
2
votes
1 answer

Error: Unexpected request: POST karma

I am getting the below error when i run my test cases, Error: Unexpected request: POST data/json/api.json it("should $watch value", function(){ var request = '/data/json/api.json'; $httpBackend.expectPOST(request).respond(200); …
ShankarGuru
  • 627
  • 1
  • 6
  • 17
2
votes
0 answers

AngularJs testing watchers with $scope variables bound

How can we test $watchers when they are linked to other $scope variables. $scope.value = 0; $scope.$watch("value", function(newValue, oldValue) { $scope.varOld = oldValue; }); I have the above piece of code, how can i test this piece of code?…
Shane
  • 5,517
  • 15
  • 49
  • 79