Giter VIP home page Giter VIP logo

Comments (20)

mattfysh avatar mattfysh commented on June 1, 2024 26

nvm, I was able to get around this by using the object format in files array:

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

from karma-browserify.

jlmakes avatar jlmakes commented on June 1, 2024 2

Both work!

  1. Using files: [{pattern: '**/*.spec.js', watched: false}] @mattfysh

or...

  1. Adding bundleDelay: 800 to Browserify's config block @nikku

Thanks!

from karma-browserify.

dchambers avatar dchambers commented on June 1, 2024 1

IMO this bug should be re-opened since using a bundleDelay timeout will never result in a system that is both reliable and performant.

I assume that what's happening here is that Karma is watching the source directories for change, then running the pre-processors and waiting for bundleDelay milliseconds before assuming they're finished? Assuming this is the case, couldn't the pre-processor be responsible for telling Karma when it's finished, so we wouldn't need the bundleDelay config in the first place?

from karma-browserify.

nikku avatar nikku commented on June 1, 2024

Could you upload a project setup somewhere that reproduces the issue?

from karma-browserify.

xdissent avatar xdissent commented on June 1, 2024

Possibly #69

from karma-browserify.

nikku avatar nikku commented on June 1, 2024

Thanks for the pull @xdissent. I am going to look into the issue in the next days.

from karma-browserify.

 avatar commented on June 1, 2024

@nikku and @xdissent, thanks for looking into it. The example project is at https://github.com/joshuabc/karma-browserify-double-run-example.

from karma-browserify.

 avatar commented on June 1, 2024

@nikku I have updated the example project with the new version and unfortunately 2.0.0 doesn't appear to have resolved this issue. Is there any additional configuration or anything that needs to be done with the upgrade?

from karma-browserify.

nikku avatar nikku commented on June 1, 2024

We have added the ability to configure the wait time before bundling and testing happens for 2.x.

Try increase it to one second or so by adding

...
  browserify: {
    bundleDelay: 1000
  }

to the karma configuration. If it helps then there exist an issue with Mac being to slow with reporting file-system changes.

@bendrucker You use Mac too, right? Could you have a look into the project and check if you can reproduce the double-run issue?

from karma-browserify.

 avatar commented on June 1, 2024

Increasing the bundleDelay to one second (1000) resolves the issue. Looks like 750 is the sweet spot for me. Thanks @nikku!

from karma-browserify.

bendrucker avatar bendrucker commented on June 1, 2024

I've definitely seen this on occasion with OS X. Upping the delay resolves it.

from karma-browserify.

ptmccarthy avatar ptmccarthy commented on June 1, 2024

I'm glad I found this issue thread and workaround, this was driving me nuts.

from karma-browserify.

demisx avatar demisx commented on June 1, 2024

Unfortunately, adding bundleDelay: 1000 didn't work for me. I am on v3.0.1. Tests still run twice every time I update one of them and click save. Here is the karma output (see below). They run once though, if I simple hit save without making any updates:

INFO [watcher]: Changed file "/Users/dmoore/projects/desktop/app/states/classified/ads/post/config_spec.js".
INFO [framework.browserify]: 558172 bytes written (0.11 seconds)
INFO [framework.browserify]: bundle updated
INFO [watcher]: Changed file "/var/folders/24/jf0__16n3pn5f62xm4w_lk4c0000gn/T/0338740b80f902106f417cc74609497e52314e97.browserify".
PhantomJS 1.9.8 (Mac OS X): Executed 2 of 2 SUCCESS (0.101 secs / 0.002 secs)

INFO [framework.browserify]: 558172 bytes written (0.12 seconds)
INFO [framework.browserify]: bundle updated
INFO [watcher]: Changed file "/var/folders/24/jf0__16n3pn5f62xm4w_lk4c0000gn/T/0338740b80f902106f417cc74609497e52314e97.browserify".
PhantomJS 1.9.8 (Mac OS X): Executed 2 of 2 SUCCESS (0.08 secs / 0.004 secs)

from karma-browserify.

bendrucker avatar bendrucker commented on June 1, 2024

This is only an issue on OS X because of delays in fsevents reporting changes. No easy fix.

from karma-browserify.

nikku avatar nikku commented on June 1, 2024

@dchambers Feel free to look into the issue and provide us with a pull request.

from karma-browserify.

mattfysh avatar mattfysh commented on June 1, 2024

The problem appears to be because some files are watched by both karma and watchify. With the following settings:

frameworks: ['browserify'],
files: ['**/*.spec.js'],
preprocessors: {'**/*.spec.js': ['browserify']}

The resulting files array has watch:true for all of the .spec.js files, as well as the bundle file added by the framework. If I change a spec file, tests execute twice. If I change a source file (only observed by watchify), tests execute only once.

I'm thinking the fix would be for the framework to grab the preprocessed files and turn off watch, will submit a pull request tomorrow :)

from karma-browserify.

MarkLeMerise avatar MarkLeMerise commented on June 1, 2024

+1 for the @mattfysh solution using the files property in the Karma config file! This was such a pain point in our workflow. Thanks for the help!

from karma-browserify.

nategeier avatar nategeier commented on June 1, 2024

thanks @nikku solved it.

from karma-browserify.

alexwakeman avatar alexwakeman commented on June 1, 2024

This article helped me fix this issue:

https://medium.com/@SchizoDuckie/so-your-karma-tests-run-twice-this-is-what-you-need-to-do-be74ce9f257e

from karma-browserify.

tonyd256 avatar tonyd256 commented on June 1, 2024

This thread is a bit old but has anyone figured out how to also include eslint into karma without the double run issue? The issue being that browserify isn't re-running eslint since it's using its own watcher. I'd rather have karma do the watching so it can decide what processors to run the files through.

UPDATE: Using eslintify as a browserify transform instead of the karma preprocessor works.

from karma-browserify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.