Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma config file - use of basePath

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!

like image 429
mindparse Avatar asked Jun 24 '15 15:06

mindparse


People also ask

What is karma config file?

Overview. In order to serve you well, Karma needs to know about your project in order to test it and this is done via a configuration file. The easiest way to generate an initial configuration file is by using the karma init command. This page lists all of the available configuration options.

What is karma config js file in angular?

The karma. conf. js file is a partial Karma configuration file. The CLI constructs the full runtime configuration in memory, based on application structure specified in the angular. json file, supplemented by karma.

What is singleRun in karma?

The property singleRun controls how Karma executes, if set to true , Karma will start, launch configured browsers, run tests and then exit with a code of either 0 or 1 depending on whether or not all tests passed.

How do I disable Karma test?

If you want to disable the Karma Test Adapter completely then use @nihique answer. However, if you still want to use Karma for your tests but do not want it to run automatically then add/update these settings in Karma's configuration file, specifically autoWatch .


1 Answers

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.

like image 75
Dallin Avatar answered Oct 01 '22 00:10

Dallin