Karma config file - use of basePath

9.1k views Asked by At

I am just trying out some things in my Karma config file, and have a files array set like so:

 files: [
  '../dist/app/**/*.mock.js',
  '../dist/assets/scripts/bower_libs.js',
  '../dist/assets/scripts/main.js',
  '../test/src/**/*.js',
  '../dist/app/**/*.spec.js'
],

I know I could use a basePath here, e.g. basePath: '../dist/' in the config, and that would remove the need to prepend '../dist/' on some of those paths. But in the case of my test folder located at the same level as dist, how would I go up a level?

Would it be this kind of thing?

basePath: '../dist/'

files: [
      'app/**/*.mock.js',
      'assets/scripts/bower_libs.js',
      'assets/scripts/main.js',
      '../test/src/**/*.js',
      'app/**/*.spec.js'
    ], 

This is probably a really dumb question, but I just wanted to be sure!

1

There are 1 answers

0
Dallin On

That should be correct. You can specify a relative path to go up one or more directories.

From the documentation:

The root path location that will be used to resolve all relative paths defined in files and exclude. If the basePath configuration is a relative path then it will be resolved to the __dirname of the configuration file.

This is one of those things that you can just try out and see if it works.