karma-runner/karma

Extract watcher into an injected dependency

Open

#1.468 geöffnet am 24. Juni 2015

Auf GitHub ansehen
 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.703 Forks)batch import
apidiscusshelp wantedtype: feature

Repository-Metriken

Stars
 (11.918 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

I'm writing a plugin that integrates Karma with Broccoli so that it can lean fully on broccoli for all pre-processing, building, etc... The reason being that if you have a Brocfile, then you already have your build toolchain defined in one place, so you might as well utilize it from your test runner. That way, instead of maintaining a parallel build systems: one for your test runner and one for development/production, you can just npm install karma-broccoli and it will know how and when to build, and also which files the build generates. I have the single run use-case working where you invoke karma run. It waits until a build runs (if there is a build), and then executes the test suite.

For the config.autoWatch use-case, I'd like to replace the normal karma watcher with the Broccoli watcher for the same reason I want Broccoli to be responsible for the build, it already knows what to to watch for and consequently, what to build. It would be nice if I could just swap out the broccoli watcher for the bundled karma watcher, but at the moment it is hard coded to the watch function in watcher.js https://github.com/karma-runner/karma/blob/master/lib/server.js#L54

While the dependencies to the watch() function are injected, the watcher itself is not, so I'd like to see if you would be open to extracting the watcher into a first-class injected dependency. If so, I'd be happy to take a stab at implementing it.

Contributor Guide