karma-runner / karma-runner/karma

(Question) Is it possible to add a file to the preprocessor file list programmatically?

Open
#2,491 2 comments 0 reactions 0 assignees View on GitHub
needs: investigation
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

I maintain the [Karma Rollup preprocessor](https://github.com/jlmakes/karma-rollup-preprocessor), and I've encountered some challenges with `autoWatch: true` and Rollup: a changed file will be reprocessed but not the dependencies it imports... so you can easily end up with stale tests.

I have hacked a solution together where I map the dependencies of each file, and manually change the accessed/modified times of those files during processing to force the Karma watcher to reprocess them as well.

The problem is that tests re-run for each manually modified file, which for a file that is used in many places can trigger a large number of re-runs.

Going through the source, I thought injecting `file-list` might be the answer so that I could manually add the dependency paths to it... but it creates a circular dependency error.

### Is it possible to add files to the preprocessor file list programmatically from within the preprocessor?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.