Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack loader test for files without certain part of filename

I keep my tests in the same folder as my components, and I'm trying to apply a webpack loader (istanbul-instrumenter-loader) to all files except the ones called exactly spec.js or that end with *Spec.js (so both components/SupportPage/spec.js and actions/SupportActionsSpec.js won't get included. I've tried getting a correct RegEx on regextester.com but I can't get it to work. Am I missing something?

like image 558
Steven Avatar asked Dec 23 '15 09:12

Steven


1 Answers

Ok, I found it. Writing a single test to include all files, but exclude the specific spec files was maybe the wrong approach, I solved it like this:

      {
        test: /.\.js$/,
        exclude: /(node_modules|bower_components)\/|.[sS]pec\.js$/,
        loader: 'istanbul-instrumenter'
      }
like image 171
Steven Avatar answered Oct 13 '22 00:10

Steven