The files array determines which files are loaded, watched and served by Karma.
The first thing you usually need is an adapter. The following adapters are bundled with Karma:
JASMINE
, JASMINE_ADAPTER
)MOCHA
, MOCHA_ADAPTER
)QUNIT
, QUNIT_ADAPTER
)REQUIRE
, REQUIRE_ADAPTER
)ANGULAR_SCENARIO
, ANGULAR_SCENARIO_ADAPTER
)If you want to use any of these, add <FRAMEWORK>
and
<FRAMEWORK>_ADAPTER
to your files
list. So for example if you want
to use Mocha you have the following in your config file:
files = [
MOCHA,
MOCHA_ADAPTER
];
basePath
#basePath
first.basePath
is a relative path, it gets resolved to the
directory where the configuration file is.test/unit/**/*.spec.js
.Since version 0.5.2 there is the ability to configure the patterns more closely.
If you define them like before a simple pattern like
'test/unit/*.js'
this gets expanded internally to the following:
{pattern: 'test/unit/*.js', watched: true, included: true, served: true}
pattern
#watched
#true
autoWatch
is true
all files that have set watched
to true will be
watched for changes.included
#true
<script>
tag? Use false
if you wanna load them manually, eg.
using Require.js.served
#true
Here is a complete example showing the different options that are possible.
files = [
// Adapter
MOCHA,
MOCHA_ADAPTER,
// simple patterns to load the needed testfiles
'test/fixtures/**/*.html',
'test/unit/*.spec.js',
// this file gets served but will be ignored by the watcher
{pattern: 'compiled/index.html', watched: false},
// this file only gets watched but otherwise ignored
{pattern: 'app/index.html', included: false, served: false}
];