Typescript support
Is there a way to write tests in typescript without compiling it manually before testing? Some kind of typescript preprocessor? I know it is possible to write tests in coffee, is it possible to do same with typescript?
At the moment, we have no special support for this. I'd be happy to take a look at a PR adding functionality if someone was interested.
Aleks, What's is your exact problem with running the compiler? We are writing our tests with typescript, compiles them automatically to javascript, and running them on protractor.
Hi all ! I don't know if this is the right place to write down this question, but I'm having some problems to run tests writen using Typescript in different classes. I want to abstract some common parts of all my test to a base test class, and then extend it from my spec files. Everything compiles correctly, but it fails when executes js files, where the prototype is not defined.
Any help on this ?
Should be "Typescript support" or "Typescript rewrite"? Given angular 2.0 will be in TS maybe Protractor should be fully rewritten in TS ;)
@elgalu maybe, but for now, we can create definitions files from jsdoc. With this https://www.npmjs.com/package/typescript-closure-tools
In my typescript projects I use tsd to manage my definitions files, includes angular-protractor. The big problem in definition files is that they are part of project independent, although they were always synchronized, even if manually!
A tool to generate here a "protractor.d.ts" will be great help for everyone.
Update here - I think a typescript rewrite is probably a far-future goal, that wouldn't give us a lot of immediate benefit.
However - we should absolutely include typescript definition files in our package. That's a high priority.
And what about a typescript preprocessor to be able to write definitions in typescript instead of ES5 js ? Or at least a babel preprocessor for some ES6?
It looks like we'll need the following definitions to write protractor tests in typescript: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/angular-protractor/angular-protractor.d.ts https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jasmine/jasmine.d.ts https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts @juliemr is there much need in the community to write tests in typescript? I definitely understand the little benefit from rewriting protractor in ts, but I'm also not seeing anything in the community on benefits of writing tests in ts, let alone successful implementation. Thanks.
Assuming this issue is about support for specs written in typescript - it would be nice with a preprocessor feature like karma offers in conjunction with browserify. This is current possible with a karma.conf as follow:
module.exports = function(config) {
config.set({
...
frameworks: ['browserify', 'jasmine'],
browserify: {
debug: true,
plugin: [['tsify', {
noImplicitAny: true,
target: 'ES5',
module: 'commonjs'
}]],
bundleDelay: 1000
},
files: [
'unit/**/*.spec.ts'
],
preprocessors: {
'unit/**/*.ts': ['browserify'],
},
...
plz correct me if I'm on a completely wrong track...
Something like @pellekrogholt outlined, as a pre-processor for TS would be awesome for anyone interested in using TS with Protractor, for now. Similar to: https://github.com/sergeyt/karma-typescript-preprocessor supporting typings too.
Some-how I could debug protractor tests from IDE (I use IntelliJ) written in pure js. Any ideas how to debug specs written in ts and converted "on-the-fly" to js?
Remaining work item: #3169
As a side note - we are specifically avoiding having preprocessors for Protractor in the line of the Karma plugins which replicate parts of the build process. You should just point Protractor at your generated .js files, and use your normal build pipeline to handle creating those.
Closing this issue since remaining work is better captured in #3169
To answer the original question: activating ts-node in a protractor.conf.js file with require('ts-node').register({ allowJs: true }) enables the use of TypeScript for all further dependencies, including spec files. (It's worth setting allowJs to true, to be able to omit the *.ts suffix when requiring/importing a module.)
If you use ts-node together with Protractor, make sure you disable Protractor's source-map-support with skipSourceMapSupport: true in your config, as ts-node brings along its own one and as the two would conflict (at this point in time).