-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watch doesn't work reliably #17
Comments
Issue #3 dealt with a very similar problem, and had a decent solution for Not perfect though, due to limitations of Karma's watcher. Which files are not triggering a new bundle? If you can put together a simple repository demonstrating the problem, I will be able much better equipped to release a fix. |
Seems to happen randomly on the same exact files. I'm experiencing it with this project. This is the config |
Your popper package is not really a simple/isolated example of the problem. Does the problem occur with any of the files in your The solution is far from ideal, but it simply stores an array of files listed as dependencies during bundling... and if a file changes, all its dependents are rebundled a well. |
It occurs with a lot—maybe all—of the files in the files array. I have not looked at the debug info, I'll take a look when I have a minute. |
I'm dropping support for Node If you have in fact uncovered a bug here, I want to make sure that the new solution solves it. Would you be willing to help me test the new release @FezVrasta? |
sure |
Alright well it'll take a bit though, I'm working on a few open source projects. |
no problem, it's just a bit annoying, nothing critical |
I too have troubles with Karma and rollup + Vue.js components. // karma.conf.js
files: [
'browser/src/tests/global.spec.js',
{pattern: 'browser/src/components/*.vue', served: false, included: false}
],
preprocessors: {
'browser/src/tests/global.spec.js': ['rollup']
}, global.spec.jsimport Vue from 'vue'
import helloTemplate from 'components/hello.vue'
import vueTemplate from 'components/test.vue'
describe('Vue components', function() {
it('has a dummy Vue.js test', () => {
const vm = new Vue({
el: document.createElement('div'),
render: (createElement) => createElement(helloTemplate)
});
expect(vm.$el.querySelector('h1').textContent).toBe('Welcome to Vue.js App')
});
it('has second Vue.js test', () => {
const vm = new Vue({
el: document.createElement('div'),
render: (createElement) => createElement(vueTemplate)
});
expect(vm.$el.querySelector('h1').textContent).toBe('hello')
});
});
So, in compiled I have to write changes in main So, we have to know how to rebuild rollup cache on file changes. In my Karma v1.3.0 server logs on dep. changes: 10 01 2017 19:34:34.179:INFO [watcher]: Changed file "/Users/menangen/WebStormProjects/game-vue-nodejs-site/browser/src/components/test.vue".
10 01 2017 19:34:45.269:INFO [watcher]: Changed file "/Users/menangen/WebStormProjects/game-vue-nodejs-site/browser/src/components/test.vue".
10 01 2017 19:34:56.501:INFO [watcher]: Changed file "/Users/menangen/WebStormProjects/game-vue-nodejs-site/browser/src/components/test.vue".
10 01 2017 19:35:12.729:INFO [watcher]: Changed file "/Users/menangen/WebStormProjects/game-vue-nodejs-site/browser/src/tests/global.spec.js". On every watcher event it would ideally recompile |
Hey @menangen, this is the same issue described in detail here. The problem is that you are only passing I assume you'll need some plugins like Something like this: files: [
'browser/src/tests/global.spec.js',
{pattern: 'browser/src/components/*.vue', served: false, included: false}
],
preprocessors: {
'browser/src/tests/global.spec.js': ['rollup'],
'browser/src/components/*.vue': ['rollup'] // now the preprocessor can see these
}, This way, the preprocessor will be able to track dependents and dependencies for both your test and the source files... so making changes to either will result in recompilation. I'm working on improving the implementation, but this is exactly what version 3 made possible. |
@jlmakes yes, it work but karma runs tests twice. First for changed .vue component and second for .spec.js main test file. If I change test file - it recompile .spec.js fast and once, if change only .vue component to broken code - karma runs 1st iteration with log about changes in .vue file and test show succes(!) pass, and on second iteration log write about changes in main .spec.js file - and now test fails. Very strange... |
This is the exact problem I'm looking to solve. There does not appear to be a way to programmatically add files to the preprocessor, so instead it has to trick Karma into rebundling them by changing their time modified. As you've pointed out, this means the tests re-run for each file that depends on the changed file. There also seems to be some issues where tests can fail, I assume due to this redundant bundling mid-test. In my personal use, it's been better having an unreliable watcher than none at all, but... All this is to say that the Karma watcher needs to be disabled, and the preprocessor needs to own the watch process (just like Webpack does). |
@jlmakes ok, I dislike Webpack and will be better use browserify like rebuild as you can test from https://github.com/vuejs-templates/browserify Also if you on Mac, you can use my testing repo with karma-rollup-preprocessor and Vue building: diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://1000000` && cd /Volumes/RAM\ Disk/ && git clone --depth 1 https://github.com/menangen/game-vue-nodejs-site.git --branch tests --single-branch && cd game-vue-nodejs-site && npm install && node_modules/.bin/karma start This shell command create RAM disk and clones my repo for playing with rollup + Karma. Also in karma.conf.js need change |
Are there any progress on this issue? Thank you! |
Hey @FezVrasta, thanks for the reminder there’s still work to be done here! The documentation is all about how to use Karma, but developing plugins requires reverse engineering existing plugins. So, I’ve been looking deeper into the Node API and wrapping my head around how the Webpack plugin handles their custom file watcher. I ended up releasing v4, which adds support for custom preprocessors (and drops support for Node 0.12), but this issue will be addressed, just bear with me a bit longer. |
Sorry again, Any progress on this issue? |
Not yet @elasim—I have not forgotten about this project—In fact, I use it every day and intend on improving it, I’ve just been busy the past few months working on another project. What Pull requests are welcome. |
There’s been issues for some time with karma watch, and the rollup preprocessor (See #17). It’s time to rebuild the preprocessor, but this time using a built-in file watcher... *presses giant red button*
Re: @FezVrasta @menangen @elasim @michaelbull I have greatly improved the file watcher in the latest major release (v5)! Also, some other important changes have been made, that coincide with the breaking changes released in
Upgrading Karma to
|
@jlmakes Thanks for your awesome work! |
Hi, first, thanks for maintaining this plugin!
I'm on
3.0.2
and Node 7, and I have a problem with the watch feature.This is my karma configuration:
Describing how my tests work, the test files
import
the source files of my library and rollup takes care to compile everything.The problem is that if I change a file in my tests, the watch task works, if instead I change a file of the source of my library, the bundle isn't updated.
Am I doing something wrong? Sometimes it works, sometimes not... randomly.
The text was updated successfully, but these errors were encountered: