karma icon indicating copy to clipboard operation
karma copied to clipboard

Karma calls Jasmine twice.

Open hpufo opened this issue 8 years ago • 2 comments

Expected behaviour

Karma calls jasmine tests once.

Actual behaviour

Everything in the describe and it functions are being called twice, causing some tests to fail.

Environment Details

  • Karma version (output of karma --version): 1.7.0
  • Relevant part of your karma.config.js file Not sure what is relevant so here is my entire file: https://gist.github.com/hpufo/2bb70a3e399ab0a486d39f67158b5567

I also tried this but the result was the same(If I set included to false, karma breaks): files: [ { pattern: 'test/**/*.tsx', watched: false, served: true, included: true } ],

Steps to reproduce the behaviour

  1. I run karma start from the console
  2. Everything in the describe and it functions are called twice.
  3. Tests that calls helper functions calls it twice resulting in the wrong return and test failing

I have created a simple mock to display this problem:

function fillArray(len: number) {
  const array = new Array(len);
  for (let i = 0; i < len; i++) {
    array.push(0);
  }
  return array;
}
describe('Karma', () => {
  console.log('DESCRIBE');
  it('runs a test and prints', () => {
    const array = fillArray(1);
    console.log(array.length);
    expect(true).toBe(true);
  });
});

Here is what the above outputs in my console(I am only including the interesting parts): image

hpufo avatar Aug 05 '17 18:08 hpufo

I haven't experienced this issue with a similar setup on the most recent version from master. Are you still experiencing this issue?

EzraBrooks avatar Dec 01 '17 01:12 EzraBrooks

I can reproduce this issue with the Karma API. Karma 4.0.1, Karma-Chrome-Launcher 2.2.0.

See the MCVE for a bare minimum example: https://github.com/is-already-taken/karma-runs-twice-mcve

is-already-taken avatar Mar 17 '19 21:03 is-already-taken