Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Typescript support #1203

Closed
aleks-sidorenko opened this issue Aug 18, 2014 · 15 comments
Closed

Typescript support #1203

aleks-sidorenko opened this issue Aug 18, 2014 · 15 comments

Comments

@aleks-sidorenko
Copy link

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?

@juliemr
Copy link
Member

juliemr commented Aug 18, 2014

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.

@omer727
Copy link

omer727 commented Oct 1, 2014

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.

@ghost
Copy link

ghost commented Mar 11, 2015

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 ?

@juliemr juliemr modified the milestones: Icebox, Upcoming Mar 17, 2015
@elgalu
Copy link
Contributor

elgalu commented Nov 20, 2015

Should be "Typescript support" or "Typescript rewrite"?
Given angular 2.0 will be in TS maybe Protractor should be fully rewritten in TS ;)

@AbraaoAlves
Copy link

@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.

@juliemr
Copy link
Member

juliemr commented Jan 4, 2016

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.

@ocombe
Copy link

ocombe commented Jan 4, 2016

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?

@mccataldo
Copy link

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.

@pellekrogholt
Copy link

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...

@magicode118
Copy link

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.

@DOrlov77
Copy link

DOrlov77 commented Apr 5, 2016

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?

@juliemr
Copy link
Member

juliemr commented Apr 26, 2016

Remaining work item: #3169

@juliemr
Copy link
Member

juliemr commented Apr 26, 2016

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.

@juliemr
Copy link
Member

juliemr commented Apr 26, 2016

Closing this issue since remaining work is better captured in #3169

@juliemr juliemr closed this as completed Apr 26, 2016
@renehamburger
Copy link

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests