From 7aeb3f84684325f1d5e0cff276b14aa059c6f6ce Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Fri, 11 Feb 2022 08:54:59 +0100 Subject: [PATCH] docs(configuration-file): document async function See https://github.com/karma-runner/karma/pull/3660 --- docs/config/01-configuration-file.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/config/01-configuration-file.md b/docs/config/01-configuration-file.md index dff4b6135..dfa0bf1cd 100644 --- a/docs/config/01-configuration-file.md +++ b/docs/config/01-configuration-file.md @@ -53,6 +53,20 @@ module.exports = (config) => { } ``` +Alternatively, you can use an `async` function instead (since v6.3). + +```javascript +// karma.conf.js +module.exports = async (config) => { + const karmaConfig = await getKarmaConfig("dev"); + + config.set({ + ...karmaConfig + }); +}; +``` + + ### Customized TypeScript Configuration Under the hood Karma uses ts-node to transpile TypeScript to JavaScript. If the resolved `tsconfig.json` has `module` configured as `ES` formats. You might get errors like `SyntaxError: Unexpected token`. This is due that in Node `ES` module formats are not supported. To overcome this issue you need to configure ts-node to use `commonjs` module format.