karma-jspm icon indicating copy to clipboard operation
karma-jspm copied to clipboard

Cannot exclude select files in the loadFiles: []

Open michaelprescott opened this issue 8 years ago • 6 comments

In my /src/*/, there are some files I don't want to load. I believe I'm using the right pattern:

loadFiles: ['src/**/(*.js|!thisfile.js)] but that causes "failed to proxy" errors

I've also tried: `loadFiles: ['src/*/.js', '!src/thisfile.js'] but it has no effect, thisfile.js is still loaded

michaelprescott avatar Dec 11 '15 19:12 michaelprescott

+1 Same for serveFiles :[]

roddolf avatar Feb 01 '16 23:02 roddolf

@roddolf For serveFiles, doesn't exclude field in karma config just work?

taak77 avatar Feb 10 '16 02:02 taak77

@taak77 The files I want to exclude are the spec files, that are in the same folder that the source files. I'm just thinking in the performance.

roddolf avatar Feb 10 '16 04:02 roddolf

@michaelprescott In your case, it will probably work if you do

loadFiles: ['src/**/!(thisfile).js']

taak77 avatar Feb 11 '16 20:02 taak77

^ Oh, so that's how it works! Thanks, that also works for me.

Would be good to have a example of this in README.

roddolf avatar Feb 11 '16 21:02 roddolf

@roddolf Glad to hear it solves your problem. It's more related to how node-glob works, not karma-jspm itself.

In my case, i'm trying to exclude any *Test.js files under certain folder, where it's e2e folder this time so that unit test won't run e2e test.

I've tried loadFiles: ['src/**/!(e2e)/**/*Test.js'] but no luck.

While we may be able to implement logic to generate the expected expanded file list using an array of glob pattern which include negation, i'm wondering if it's better to introduce excludeFiles config to exclude certain files from loadFiles list since it's much easier to implement and aligns with what Karma has with files and exclude.

Once I have excludeFiles field, I can achieve what i need by

jspm: {
  loadFiles: ['src/**/*Test.js'],
  excludeFiles: ['src/**/e2e/**/*Test.js']
}

Any thoughts?

taak77 avatar Feb 11 '16 22:02 taak77