Skip to content

Commit

Permalink
Merge a82a1a8 into 9d66192
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops authored May 19, 2020
2 parents 9d66192 + a82a1a8 commit 4596bef
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions docs/config/01-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,12 @@ module.exports = (config) => {
```

### 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.
Under the hood Karma uses [ts-node](https://github.com/TypeStrong/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.

Create a JavaScript configuration file that overrides the module format.
```javascript
// karma.conf.js
require('ts-node').register({
compilerOptions: {
module: 'commonjs'
}
});
require('./karma.conf.ts');
To use a TypeScript configuration file rename the existing `karma.conf.js` to `karma.conf.ts` and install `ts-node` and `typescript`:

```bash
npm install ts-node typescript --save-dev
```

## File Patterns
Expand Down

0 comments on commit 4596bef

Please sign in to comment.