computmaxer / karma-jspm

Other
74 stars 50 forks source link

Cannot exclude select files in the loadFiles: [] #117

Open michaelprescott opened 8 years ago

michaelprescott commented 8 years ago

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

roddolf commented 8 years ago

+1 Same for serveFiles :[]

taak77 commented 8 years ago

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

roddolf commented 8 years ago

@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.

taak77 commented 8 years ago

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

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

roddolf commented 8 years ago

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

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

taak77 commented 8 years ago

@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?