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

Can Karma refresh the file changes without running the whole suite again?

I am using Karma through Grunt. We have around 1000 tests and it is a bit painful to have them all run whenever we change a file (autoWatch = true). This is what we are doing now: Start Karma with singleRun=false, autoWatch=false. Open the debug…
4lejandrito
  • 182
  • 1
  • 6
4
votes
1 answer

Mocha & Chai- "timeout of 2000ms exceeded. Ensure the done() callback is being called in this test."

I'm getting " timeout of 2000ms exceeded. Ensure the done() callback is being called in this test." while unit testing a service call that responds back with a promise. I am expecting a rejected promise. UNIT TEST - Karma-Mocha-Chai running on…
Alexander
  • 105
  • 7
4
votes
1 answer

karma require js relative path not working

I'm trying to make test environment for my javascript project but I got problem because of There is no timestamp for Issue and WARN [web-server]: 404: /base/app/templates/setting.html, my templates located in different folder with base folder. here…
4
votes
1 answer

How to get filename of the test in mocha reporter

Is there a way to get the filename of current test in mocha reporter? I couldn't find anything in the base and examples.
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
4
votes
1 answer

How does one write unit tests in Karma that interact with SVG graphics using Snap.svg?

I am working on a web app that uses SVG graphics for most of its display and interaction. I would like to use Karma to create unit tests that load an SVG asset, makes sure that certain groups/paths are present, etc. I haven't found any…
jmcmichael
  • 611
  • 1
  • 7
  • 11
3
votes
1 answer

Karma - NullInjectorError: No provider for HttpClient

I get NullInjectorError: No provider for HttpClient when i run my test. Using Angular 8 with Karma. I followed examples and am new to Karma. So not sure why this is happening. Why? Most of what i read says to include the httpclienttesting…
Chris
  • 141
  • 3
  • 13
3
votes
2 answers

Diagnosing duplicate spec reporting with Karma, Mocha, and React 16.5

I have a project using React for the view layer. To test it, I am using mocha, karma, karma-webpack, etc. For some reason, in React 16+, karma is reporting the afterEach as having run three times for two specs. This happens only in React 16+ and…
jneander
  • 1,150
  • 14
  • 34
3
votes
1 answer

Converting newly created angular cli project to use mocha framework instead of jasmine

Hey i created a new project with latest angular cli. It creates a project that uses jasmine as the testing framework. I wanted to use mocha. I added the required plugins following the project…
3
votes
1 answer

How to add Karma+Mocha tests after initializing project using vue-cli

Hi I started a project using Vue-cli webpack the mistake I did was I did not enable tests How do I add karma+mocha to my webpack vuejs2 development is it possible to reinitialize and include tests ?
f4r4
  • 563
  • 8
  • 19
3
votes
0 answers

Karma, Mocha, Chrome Headless and click testing on an url

I'm trying to use Karma & Chrome Headless to replace testing I would have done with CasperJS & PhantomJS to load a public site for running end to end click testing. The idea is that this would be an automated test against a canary server to ensure…
3
votes
1 answer

Karma - TypeScript - Can't find variable: exports

I am learning to write Unit Test cases for an angular project written in Typescript. I have chosen Karma and Mocha for that. Here is the application structure: Project/ ├── app/ │ └── components/ │ └── mycoolcomponent/ │ ├──…
Saurabh R S
  • 3,037
  • 1
  • 34
  • 44
3
votes
0 answers

unexpected token import using karma with webpack and babel

I'm trying to run karma tests using karma, webpack and babel. I feel like I've configured properly but it seems that the test files are not being transpiled. karma.conf: module.exports = function(config) { config.set({ basePath: '', …
Cathal
  • 1,740
  • 18
  • 31
3
votes
2 answers

How to assert if an element exists in angular?

I am writing a spec for a directive. As part of the testing, I need to assert if an element with a class exists inside my root directive component. I have tried the following. it('should have a loading div container', function() { var…
3
votes
0 answers

Debugging Karma, mocha & webpack inside IntelliJ

I am failing to debug mocha unit tests, using karma and webpack. I have the Karma plugin installed, and the chrome extension. But when I'm debugging the IDE would just ignore any breakpoints. Example of a unit test: var assert =…
Ohad Navon
  • 1,693
  • 1
  • 14
  • 19
3
votes
0 answers

enzyme find can't find the child element under a dom

I am using karma, enzyme, chai as test framework for a react project. Below is the code I used in my test case. I used redux-mock to mock the store state. const initialState = { } const store = mockStore(initialState) describe('test suite', () => { …
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523