karma-runner / karma-runner/karma

Extract watcher into an injected dependency

Open
#1,468 6 comments 0 reactions 0 assignees View on GitHub
api discuss help wanted type: feature
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

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

Open the contributing guide

Research direction

Start with lib/server.js around the hard-coded watch function and inspect watcher.js, focusing on the config.autoWatch path and the existing watch() dependencies. The work is complete when the watcher is a first-class injected dependency that can be replaced by a Broccoli watcher without changing the normal watcher behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.