diff --git a/docs/config/02-files.md b/docs/config/02-files.md index f85c4d772..aac9304e0 100644 --- a/docs/config/02-files.md +++ b/docs/config/02-files.md @@ -1,28 +1,14 @@ -**The `files` array determines which files are included in the browser and which files are watched and served by Karma.** +The `files` array determines which files are included in the browser, watched, and served by Karma. - -## Pattern matching and `basePath` -- All of the relative patterns will get resolved using the `basePath` first. -- If the `basePath` is a relative path, it gets resolved to the - directory where the configuration file is located. -- Eventually, all the patterns will get resolved into files using - [glob], so you can use [minimatch] expressions like `test/unit/**/*.spec.js`. - - -## Ordering -- The order of patterns determines the order in which files are included in the browser. -- Multiple files matching a single pattern are sorted alphabetically. -- Each file is included exactly once. If multiple patterns match the - same file, it's included as if it only matched the first pattern. - - -## Included, served, watched -Each pattern is either a simple string or an object with the following properties: +## `files` +**Type.** Array +**No Default.** This property is mandatory. +**Description.** Each item is either a string (equivalent to `{ pattern: "" }`) or an object with the following properties: ### `pattern` * **Type.** String * **No Default.** This property is mandatory. -* **Description.** The pattern to use for matching. +* **Description.** The pattern to use for matching. See below for details on how patterns are resolved. ### `type` * **Type.** String @@ -68,6 +54,18 @@ Each pattern is either a simple string or an object with the following propertie * **Default.** `false` * **Description.** Should the files be served from disk on each request by Karma's webserver? +## Pattern matching and `basePath` +- All of the relative patterns will get resolved using the `basePath` first. +- If the `basePath` is a relative path, it gets resolved to the + directory where the configuration file is located. +- Eventually, all the patterns will get resolved into files using + [glob], so you can use [minimatch] expressions like `test/unit/**/*.spec.js`. + +## Ordering +- The order of patterns determines the order in which files are included in the browser. +- Multiple files matching a single pattern are sorted alphabetically. +- Each file is included exactly once. If multiple patterns match the + same file, it's included as if it only matched the first pattern. ## Preprocessor transformations Depending on preprocessor configuration, be aware that files loaded may be transformed and no longer available in @@ -100,6 +98,30 @@ files: [ ], ``` +## Loading files from another server + +Pattern can also be an absolute URL. This allows including files which are not served by Karma. + +Example: + +```javascript +config.set({ + files: [ + 'https://example.com/my-lib.js', + { pattern: 'https://example.com/my-lib', type: 'js' } + ] +}) +``` + +Absolute URLs have some special rules comparing to the regular file paths: + +- Globing is not support, so each URL must be specified as a separate pattern. +- Most of the regular options are not supported: + - `watched` is always `false` + - `included` is always `true` + - `served` is always `false` + - `nocache` is always `false` + ## Loading Assets By default all assets are served at `http://localhost:[PORT]/base/`