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

Test if Element exists Vuejs, Karma, Mocha

I'm new to testing in Javascript and Vue.js. I installed vue via vue-cli and the full webpack template that has Karma, Mocha, and PhantomJS built in. I ran the hello world component test and it passes. I have a vuejs component called my-input.vue…
nu everest
  • 9,589
  • 12
  • 71
  • 90
8
votes
3 answers

Karma+Mocha+React Cannot convert a Symbol value to a string

I am using webpack+babel for a React+Redux app and Mocha+Karma for testing. The redux test cases are getting executed properly. However, when I try to do DOM testing using react-addons-test-utils and running it with Karma it gives this error…
pratyush jha
  • 143
  • 1
  • 2
  • 7
8
votes
2 answers

Angular karma phantom before each hook error

I am running my tests with karma and phantom, i am using mocha and sinon and sometimes the tests pass and sometimes without any reason i get this errors: ✖ "before each" hook: workFn ✔ should call get user api ✖ "after each" hook for…
user233232
  • 6,067
  • 9
  • 29
  • 37
8
votes
2 answers

Can not load "mocha" framework on karma configuration file while executing gulp task

While executing gulp test-browser command, I got following warning message WARN [reporter]: Can not load "mocha", it is not registered! Perhaps you are missing some plugin? but if i execute karma start command its working fine and it not…
codeninja.sj
  • 3,452
  • 1
  • 20
  • 37
8
votes
4 answers

How to make mocha fail when no expect within it()

Is there an option to set mocha to report test as failing in case no expect provided within it() function? Idea is workflow to be like this: add one it() with desc and callback function the it() is reported as fail since no expectation is set in…
gee6
  • 83
  • 5
7
votes
0 answers

why does fetchmock restore give unmatched get?

I have written logic based on test cases already defined.Basically the tc checks for one server call below is the code.How do I modify my logic to make the tc pass? this is test case: it('there shall be only one server call in addFavourites()',…
7
votes
1 answer

Test case to check if Button onClick opens a new tab

I am new to UI development and recently I have started to write code in React using Typescript. I have created a Button and after clicking the same, it opens a menu with some options to select from. If I click on one of the option a new tab will be…
Dhiraj
  • 113
  • 3
  • 7
7
votes
1 answer

How can I include Mocha and Karma tests (server-side and client-side) in the same codebase / package.json?

I have 2 test files in ./test. Let's say test1.js is a Mocha test that spins up a server and runs various requests against URIs to determine that they all behave as expected. test2.js is a Mocha test that uses Karma to load specific scripts…
Charlie Schliesser
  • 7,851
  • 4
  • 46
  • 76
7
votes
1 answer

Module not found: Error: Cannot resolve module 'react-addons-test-utils'

I have an ES6 project in which I use webpack to convert the client code to ES5. The project uses ReactJS on the client side so, naturally, the unit tests use the React TestUtils. In the most recent update (0.14), React changed how several modules…
CivBase
  • 255
  • 2
  • 7
7
votes
6 answers

How do I run only certain tests in karma?

I have karma config set up correctly, config file, running in the background, just great. As soon as I change and save a file, it reruns the tests.... all 750 of the unit tests. I want to be able to run just a few. Short of manually hacking the…
deitch
  • 14,019
  • 14
  • 68
  • 96
6
votes
1 answer

Error in Unit Test VueJS component with Vuex

Error: undefined is not a constructor (evaluating 'vm.$el.querySelector('h3')') Follow my code and full code here // main.js import Vue from 'vue' import App from './App' import router from './router' import store from './store' import…
ridermansb
  • 10,779
  • 24
  • 115
  • 226
6
votes
7 answers

TypeError: angular.element.cleanData is not a function

I'm getting the following error in my karma unit test when trying to use inject() Example ✗ should wait for promise to resolve and have a result Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test. …
chovy
  • 72,281
  • 52
  • 227
  • 295
6
votes
1 answer

How to test Angular $modal using Sinon.js?

I am trying to write Unit tests for a $modal in AngularJS. The code for the modal is located in a controller as follows: $scope.showProfile = function(user){ var modalInstance = $modal.open({ …
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191
5
votes
3 answers

How to test DOM update in Vue.js with Mocha?

I'm struggling to understand some basic concepts of unit testing in Vue.js using Karma, Mocha and Chai. This is my component: VueExample.vue