Does Karma resolve a relative basePath against the config file or the CI working directory?
0 reputation · 20 Feb 2020, 04:33 UTC
One config file, two effective roots
A shared karma.conf.js is expected to drive both local watch runs and CI single runs; assume Karma 6.x. Karma's documented rule is that a relative basePath resolves against the location of the configuration file itself. Pipelines that generate the config into a temporary directory, wrap it in a build tool, or launch the runner from another working directory can still shift the effective root, changing which entries the files, exclude, and preprocessors patterns pick up.
Two constraints complicate a one-line fix. Watch mode and singleRun manage the served file set differently, so a resolution divergence may surface in only one mode. A Karma 7 upgrade may also require coverage reporter configuration changes, raising the stakes of pinning this behavior now.
Three points would settle the design:
- Is relative
basePathresolution strictly anchored to the config file's directory, regardless of the invoking working directory? - Do watch and single-run modes resolve the initial file list through the same path, so a root mismatch must appear in both?
- Would anchoring
basePathwith__dirnameremove the ambiguity without altering served URLs thaturlRootor proxies rely on?