Allow for karma.conf.ts (TypeScript) when using cli
See original GitHub issueWhen running node_modules/.bin/karma start karma.conf.ts
(1) (written in TypeScript) I get:
ERROR [config]: Invalid config file!
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.parseConfig (node_modules/karma/lib/config.js:276:22)
at new Server (node_modules/karma/lib/server.js:56:20)
at Object.exports.run (node_modules/karma/lib/cli.js:231:7)
at Object.<anonymous> (node_modules/karma/bin/karma:3:23)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
Also it does not seem to automatically detect karma.conf.ts
when running node_modules/.bin/karma start
:
[karma]: No captured browser, open http://localhost:9876/
INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
INFO [Chrome]: Connected on socket 9S-HxtcaP6-xFCRfAAAA with id manual-8425
Chrome ERROR
You need to include some adapter that implements __karma__.start method!
On the other hand when running the task using gulp and the same karma.conf.ts
:
// File gulpfile.ts (written in TypeScript)
import * as gulp from 'gulp';
import * as karma from 'karma';
function runKarma(done): void {
const config = {
configFile: __dirname + '/karma.conf.ts'
};
const server = new karma.Server(config, done);
server.start();
}
gulp.task('test', done => runKarma(done));
Everything works as expected so I suspect code specific to the cli to not support TypeScript.
(1) or $(npm bin)/karma start karma.conf.ts
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Configuration File - Karma
The easiest way to generate an initial configuration file is by using the karma init command. This page lists all of the available...
Read more >Karma Config - JavaScript Dev Tools
Karma Config will auto-detect most CI environments. This option can also be enabled by setting the CI or KARMA_CI environment variables.
Read more >Unable to load *.vue files using karma and karma-typescript
I was able to produce a webpack.config.js using "vue inspect" and created a webpack.config.js file locally within the root of the project. karma...
Read more >Karma Configuration - Rangle.io : Angular Training
Karma is the foundation of our testing workflow. It brings together our other testing tools to define the framework we want to use,...
Read more >karma-typescript - npm
Simplifying running unit tests with coverage for Typescript projects.. Latest version: 5.5.3, last published: a year ago.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works for me using TypeScript 2:
In
package.json
:Also don’t forget to add this to your karma config file:
Then run
npm test
Even with this merged (https://github.com/karma-runner/karma/pull/2224) I still can’t figure out how to use ES6 modules. Is this supported. I get the following error: