diff --git a/docs/config/01-configuration-file.md b/docs/config/01-configuration-file.md index dfa0bf1cd..f839d94e7 100644 --- a/docs/config/01-configuration-file.md +++ b/docs/config/01-configuration-file.md @@ -81,6 +81,36 @@ require('ts-node').register({ require('./karma.conf.ts'); ``` +### Asynchronous Configuration + +The function exported by the configuration file may return a promise whose +resolution will tell Karma when all configuration is complete, including the +final call to `config.set()`. + +```js +// karma.conf.js +const getAsyncConfig = require('./getAsyncConfig.js'); + +module.exports = async (config) => { + const asyncInfo = await getAsyncConfig() + config.set({ + basePath: '../..', + frameworks: ['jasmine'], + // ... other Karma configuration + // ... including the use of `asyncInfo` + }); +} +``` + +Just as with a synchronous configuration's return value not being used, an +asynchronous configuration's resolved value will not be used. With both +configuration types, `config.set()` MUST BE called to assign the configuration +object. + +If you are using the `parseConfig` method from the public API, then please see +the [Public API Documentation][dev/public-api] for details, usage, and +addtional information. + ## File Patterns All of the configuration options, which specify file paths, use the [minimatch][minimatch] library to facilitate flexible but concise file expressions so you can easily list all of the files you want to include and exclude. @@ -526,7 +556,7 @@ The plugin must provide an express/connect middleware function (details about th function CustomMiddlewareFactory (config) { return function (request, response, /* next */) { response.writeHead(200) - return response.end("content!") + return response.end('content!') } } ``` @@ -890,5 +920,6 @@ If you see this error, you can try increasing the socket connection timeout. [config/files]: files.html [config/browsers]: browsers.html [config/preprocessors]: preprocessors.html +[dev/public-api]: ../dev/public-api.html [log4js]: https://github.com/nomiddlename/log4js-node [minimatch]: https://github.com/isaacs/minimatch