question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When karma is auto-watching files, karma-webpack causes tests to occasionally run twice, possibly OS X-only

See original GitHub issue

I have a larger project set up using gulp with karma’s watch to run tests on the fly.

I noticed that frequently when making updates to test files karma is watching, the tests get fired twice. After paring down my configurations, it looks like karma-webpack is the culprit.

I’m on OS X, so hopefully the repro works on whatever platform. Here are instructions/a barebones repo to isolate the issue and reproduce:

https://github.com/alanctkc/karma-webpack-watch-bug-repro#readme

Here’s a comparison of the output I get simulating changes with and without the ['webpack'] preprocessor:

https://gist.github.com/alanctkc/79c2c4586f13f22bd8e6

Unfortunately, it doesn’t seem to be super deterministic, so you might have to simulate changes a few times before seeing any duplicates. But, when the preprocessor is removed, there never seem to be any duplicate runs at all.

Any ideas?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
milimetriccommented, Jun 21, 2017

I got my config to work (it no longer runs tests twice) based on the browserify example mentioned above. Here it is for clarity:

{
    ...

    frameworks: ['jasmine-ajax', 'jasmine'],

    files: [{
        pattern: './test/**/*.spec.js',
        watched: false,
        included: true,
        served: true
    }],

    preprocessors: {
        './test/**/*.spec.js': ['webpack']
    }
}
0reactions
joshwienscommented, Jul 26, 2016

Issue has multiple resolutions. Resolving

Read more comments on GitHub >

github_iconTop Results From Across the Web

When karma is auto-watching files, karma-webpack causes ...
When karma is auto-watching files, karma-webpack causes tests to occasionally run twice, possibly OS X-only #44.
Read more >
Avoid karma tests running twice on autoWatch - Marco Pracucci
Karma is configured with autoWatch: true , so tests automatically run each time any file changes. Unfortunately, tests did run twice each time ......
Read more >
Karma run test cases double times - Stack Overflow
I've had the same problem and it's because the '*.spec.js' files need to be accessible but not included, so you have to do...
Read more >
Efficient TDD with Karma and Webpack - Bamboo Engineering
Karma will see that a new file has been generated and will automatically serve it to the browser, this is due to setting...
Read more >
Karma Config - JavaScript Dev Tools
It can reduce a typical karma.config.js file from dozens of lines to just two or ... This makes it easy to detect which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found