Comments (20)
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.
Both work!
- Using
files: [{pattern: '**/*.spec.js', watched: false}]
@mattfysh
or...
- Adding
bundleDelay: 800
to Browserify's config block @nikku
Thanks!
from karma-browserify.
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.
Could you upload a project setup somewhere that reproduces the issue?
from karma-browserify.
Possibly #69
from karma-browserify.
Thanks for the pull @xdissent. I am going to look into the issue in the next days.
from karma-browserify.
@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.
@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.
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.
Increasing the bundleDelay
to one second (1000) resolves the issue. Looks like 750 is the sweet spot for me. Thanks @nikku!
from karma-browserify.
I've definitely seen this on occasion with OS X. Upping the delay resolves it.
from karma-browserify.
I'm glad I found this issue thread and workaround, this was driving me nuts.
from karma-browserify.
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.
This is only an issue on OS X because of delays in fsevents reporting changes. No easy fix.
from karma-browserify.
@dchambers Feel free to look into the issue and provide us with a pull request.
from karma-browserify.
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.
+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.
thanks @nikku solved it.
from karma-browserify.
This article helped me fix this issue:
from karma-browserify.
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)
- intellij karma runner doesn't use watchify for bundle rebuild HOT 3
- Cannot read property 'bundleFile' of undefined HOT 2
- Error: Cannot find module HOT 2
- Use global transforms HOT 4
- ERROR [framework.browserify]: Error: Cannot find module HOT 2
- attempting to use node-underscorify with karma-browserify fails HOT 2
- Missing repo nikku/node-browserify breaks older versions (<4.0) HOT 1
- Karma not working with Firefox(FirefoxHeadless) when loading with html page. HOT 1
- Unable to browserify file HOT 1
- Install issues due to browserify peerDependecy condition HOT 1
- karma-browserify HOT 1
- lodash vulnerability reported by "npm audit" HOT 1
- When packaged, my test coverage is always 100% HOT 4
- release with PhantomJS removed? HOT 1
- promisify is not a function HOT 2
- Using karma-browserify with WASM HOT 2
- Cannot use import statement outside a module only on karma-browserify HOT 3
- Support for Browserify v17 HOT 2
- Breaking change coming for karma-browserify/lib/preprocessor.js HOT 4
- Support watchify <= 4 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-browserify.