karma
karma copied to clipboard
Glob Brace Expansion Doesn't Work For `config.files`
I want to run & preprocess files for the following extensions:
-
.cjs
-
.js
-
.jsx
-
.mjs
-
.ts
-
.tsx
I can accomplish this with a single preprocessors
entry, but I need at least two files
entries.
config.set({
// ... other config
files: [
{pattern: 'src/**/*.test.[jt]s?(x)', watched: false}, // js | jsx | ts | tsx
{pattern: 'src/**/*.test.[cm]js', watched: false} // cjs | mjs
],
preprocessors: {
'src/**/*.test.{[jt]s?(x),[cm]js}': ['webpack'], // All 6 extensions
},
})
Setting aside the unlikelihood of any single project ever needing to work with all these extensions: as far as I can tell, brace expansion seems to be disabled for files
. Is this intentional or a bug?
The docs don't say anything on the matter, one way or the other, though I'm leaning towards this is bug thanks to the following:
... all the patterns will get resolved into files using glob, so you can use minimatch expressions
Both Glob and Minimatch have support for brace expansion.
I've been digging around in the code to try to get more information, but I'm not yet sure I have the correct files to dive deeper into.
I think it is just for historical reasons. And I agree that it would make sense to support braces expansion in files
as well.
AFAICT preprocessors use minimatch
, but files use glob
. Maybe just a matter to pass a flag, because they have different defaults, not sure. In any case, PR would be welcome to allow brace expansions for files. But note that it is a pretty dangerous change, so we'll probably hold with the merge until the next major.