karma-typescript is a Karma plugin designed to simplify running unit tests for TypeScript projects. It seamlessly integrates TypeScript compilation, type checking, and test execution within the Karma test runner without requiring separate build steps. It also provides remapped test coverage reports via Istanbul, ensuring accurate coverage data even after transpilation. The current stable version is 5.5.4, with recent releases focusing on bug fixes and compatibility updates for newer versions of Karma and TypeScript. Its key differentiators include built-in type checking, automatic source map generation for debugging, and robust remapped coverage reporting, making it a comprehensive solution for testing TypeScript code.
npm install karma-typescriptVerified import paths — ran on the pinned version, not inferred.
This configuration sets up Karma with Jasmine and karma-typescript to compile and run tests on TypeScript files located in the 'src' directory, producing remapped coverage reports.
Upgrade Karma to a compatible version (e.g., `npm install karma@^6 --save-dev`) and ensure `typescript` peer dependency is met. Refer to the `peerDependencies` section for exact ranges.
Ensure you are using `karma-typescript@5.4.0` or higher to avoid issues present in version 5.3.0. Always check the latest patch releases for bug fixes.
Upgrade to `karma-typescript@5.5.2` or newer to ensure the correct `acorn` dependency is available and avoid test run lockups. If issues persist, try `npm install acorn` explicitly.
Update to `karma-typescript@5.4.0` or newer, which includes a fix to prevent the process from being killed when coverage thresholds aren't met in `singleRun: false` mode.
Upgrade `karma-typescript` to the latest patch release (e.g., `npm install karma-typescript@latest --save-dev`) or explicitly install `acorn`: `npm install acorn --save-dev`.
Ensure `karma-typescript` is listed in the `frameworks` array in your `karma.conf.js`: `frameworks: ["jasmine", "karma-typescript"],`
Adjust the coverage thresholds in your `karma.conf.js` under `karmaTypescript.coverageOptions.threshold`, or set `karmaTypescript.coverageOptions.failOnThresholdNotMet: false` if you do not want failures on unmet thresholds.
Review the accompanying TypeScript error message and fix the code. Ensure your `tsconfig.json` or `karmaTypescript.compilerOptions` are correctly configured for your project.