-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for karma.conf.ts (TypeScript) when using cli #1727
Comments
I'm afraid Karma does not support TypeScript at all in configuration files. Not sure why it works when you use it through gulp (maybe some part of your build process handles it somehow, or more likely it is just processed by node with support for ES2015 instead of TypeScript, as your config files looks like it does not use anything that is actually TypeScript specific only ES2015 modules) |
I guess this is the answer. I've added some debug infos inside ts-node: $ gulp test
[13:03:41] Requiring external module ts-node/register
DEBUG node_modules/ts-node/dist/ts-node.js compile(fileName), fileName: gulpfile.ts
[13:03:43] Using gulpfile gulpfile.ts
[13:03:43] Starting 'test'...
DEBUG node_modules/ts-node/dist/ts-node.js compile(fileName), fileName: karma.conf.ts
INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
[...] As you can see, ts-node automatically compiles karma.conf.ts without me asking for it. I like to write karma configuration file in TypeScript so I can use TypeScript definition for karma. It works nicely and if one day a karma parameter changes, I will be notified thx to the TypeScript definition. // File karma.conf.ts (written in TypeScript)
/// <reference path="node_modules/DefinitelyTyped/karma/karma.d.ts" />
import * as karma from 'karma';
export = (config: karma.Config) => {
config.set({
// ...
}):
}; Also TSLint does the linting on all my *.ts files including karma.conf.ts. |
I prefer this as well, mostly for consistency and tooling reasons. |
This is currently blocked by gulpjs/rechoir#26 to work. When finished this will fix #2180,#1597,#1727
Even with this merged (#2224) I still can't figure out how to use ES6 modules. Is this supported. I get the following error:
|
I noticed ngParty/Angular1-scaffold@db2a25d was running into this issue as well. If type annotations cannot be used it negates the benefit of TypeScript support.
I think the ts-node register call needs to support some options |
This works for me using TypeScript 2:
In {
"scripts": {
"test": "ts-node node_modules/karma/bin/karma start karma.conf.ts",
},
} Also don't forget to add this to your karma config file:
Then run |
The Karma Configuration documentation writes:
The documentation also lists
|
When running
node_modules/.bin/karma start karma.conf.ts
(1) (written in TypeScript) I get:Also it does not seem to automatically detect
karma.conf.ts
when runningnode_modules/.bin/karma start
:On the other hand when running the task using gulp and the same
karma.conf.ts
: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
The text was updated successfully, but these errors were encountered: