Skip to content
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

Please add support for TypeScript #335

Closed
Chris2011 opened this issue May 13, 2015 · 33 comments
Closed

Please add support for TypeScript #335

Chris2011 opened this issue May 13, 2015 · 33 comments

Comments

@Chris2011
Copy link

I created a lib with typescript and my tests are written in typescript too. I really would like to try cucumber.js and create step definition files, with typescript. So you support coffeescript and js, .ts would be nice too.

Regards

Chris

@aslakhellesoy
Copy link
Contributor

Why don't you send a pull request @Chris2011

@Chris2011
Copy link
Author

I will be only a customer of this project, when I do each pull request of each stuff what I use and there is some missing, than I can create it by my own. It is only a feature request. If someone has time and would like to do it, why not. Me not, because I don't have time, I have the same normal work and other projects and don't want to be a contributor on each project that I use. Sry for the harsh words maybe but for me it is clear that it is not possible to be a contributor on each project, what I use. I have to understand the source and so on.

@aslakhellesoy
Copy link
Contributor

I understand @Chris2011. Maybe one day someone will decide to spend time implementing this because they want to help you, or just for fun.

The more realistic scenario is that this feature request stays open until someone needs it enough to be willing to spend the time and effort to implement it and send a PR.

@Chris2011
Copy link
Author

Maybe. Thx for your opinion. In my perspective, it was only logic to ask for this feature because TS will be more popular as for 1 or 2 years. And when you or whoever decided to implement coffeescript too, why not typescript too?

Thx a lot. We will see what happens...

@jbpros
Copy link
Member

jbpros commented Jun 5, 2015

In general - just like formatters - I'd like to have language/dialect support to be 3rd party plugins instead of part of the core (including the current CoffeeScript and PogoScript).

@jbpros jbpros added this to the icebox milestone Jun 8, 2015
@ruslango
Copy link

TS +1

@laland
Copy link

laland commented Jul 23, 2015

+1

@RokaFogtaCsukaFarka
Copy link

Like it, pls do it some time!!!

@AbraaoAlves
Copy link

👍

@aslakhellesoy
Copy link
Contributor

No amount of +1 or 👍 will make this happen. Someone has to submit a pull request.

@samccone
Copy link
Member

👍 @aslakhellesoy spot on

@aslakhellesoy
Copy link
Contributor

🎱 @samccone

@mkusher
Copy link

mkusher commented Aug 6, 2015

@jbpros @aslakhellesoy the only thing should be done to support 3rd party languages is implementing way to modify:

SupportCodePathExpander.SUPPORT_CODE_FILES_IN_DIR_REGEXP = /\.(js|coffee|pogo)$/;

And then anyone can register any transpiler in support/env.js for example
maybe this regex should be removed at all?

@SeanFarrow
Copy link

I'm happy to look at this. I can find the coffeeScript feature file but can't find where the step definitions are implemented, please could someone give me some pointers as to what needs to be done?

@mkusher
Copy link

mkusher commented Aug 16, 2015

@SeanFarrow I've already done it locally. You have just to modify /lib/cucumber//cli/argument_parser/support_code_path_expander.js:12 and then add any transpiler via require hook

@SeanFarrow
Copy link

Are you ghoing to send a pr?

From: Aleh Kashnikau [mailto:notifications@github.com]
Sent: 16 August 2015 19:15
To: cucumber/cucumber-js cucumber-js@noreply.github.com
Cc: Sean Farrow sean.farrow@seanfarrow.co.uk
Subject: Re: [cucumber-js] Please add support for TypeScript (#335)

@SeanFarrowhttps://github.com/SeanFarrow I've already done it locally. You have just to modify /lib/cucumber//cli/argument_parser/support_code_path_expander.js:12 and then add any transpiler via require hook


Reply to this email directly or view it on GitHubhttps://github.com//issues/335#issuecomment-131598410.

@jbpros
Copy link
Member

jbpros commented Aug 19, 2015

@mkusher there is more to it. To be complete, step definitions snippets should also be available in the additional language (which is currently not done for PogoScript), see the CLI --coffee flag.

I'd really like this to be done via a plugin/transpiler system anyway and remove all dialects from core (including coffeescript).

@henrify
Copy link

henrify commented Sep 10, 2015

I don't understand why language specific support is even needed? Wouldn't you just transpile the step definitions to JavaScript as part of your build process?

@charlierudolph
Copy link
Member

#398 should make supporting any transpiler simple

@jbpros
Copy link
Member

jbpros commented Sep 23, 2015

Yep, #398 will fix this.

@henrify the only thing that "needs" to be added to Cucumber is the step definition snippet support for other languages. Currently they're in vanilla JS by default and can be output in CS with the --coffee CLI flag.

We might just drop non-JS snippets altogether (including CS?). Thoughts?

@jbpros
Copy link
Member

jbpros commented Sep 24, 2015

#398 has been merged and will be available in the next release. TypeScript support is documented in the README.

@jbpros jbpros closed this as completed Sep 24, 2015
@JoshuaKGoldberg
Copy link
Contributor

@jbpros since the readme's been updated, and this shows prominently in results for "cucumber typescript", an excerpt:

Transpilers

-Step definitions and support files can be written in other languages that transpile to javascript.
-This done with the CLI option --compiler <file_extension>:<module_name>. For CoffeeScript 1.10.0,
-this is done with --compiler coffee:coffee-script/register.
Step definitions and support files can be written in other languages that transpile to javascript. This done with the CLI option --compiler <file_extension>:<module_name>.

CoffeeScript

Install the coffee-script NPM package and invoke Cucumber with --compiler coffee:coffee-script/register.

TypeScript

Install the typescript-node NPM package and invoke Cucumber with --compiler ts:typescript-node/register.

As usual, all your step definition and support files must export a function to be run by Cucumber. This is how it is done in TS:

declare var module: any;
module.exports = function () {
 this.Given(/.*/, function () {
   // ...
 })
}

PogoScript

Install the pogo NPM package and invoke Cucumber with --compiler pogo:pogo.

@Chris2011
Copy link
Author

Is it really needed to use typescript-node? Is it possible to use the official supported tsc instead of typescript-node? I don't know the differences but tsc is official supported from Microsoft.

@mkusher
Copy link

mkusher commented May 25, 2016

@Chris2011 ts-node is just a register hook for node.js that will run compilation via tsc

@Chris2011
Copy link
Author

Ok thx.

@TimMurphy
Copy link

@JoshuaKGoldberg where is the excerpt from? My searches have failed to find it.

@AbraaoAlves
Copy link

AbraaoAlves commented Sep 19, 2016

A sample to guide you in the cucumberjs with typescript use:
https://github.com/AbraaoAlves/cucumber-protractor-typescript-boilerplate

@jlamandecap
Copy link

Thanks @AbraaoAlves for the sample.
Unfortunately, it only works with cucumberjs 1. The protractor-cucumber-framework layer is not compatible with the cucumber2 rcs.

@Rajazpandi
Copy link

how to attach screenshot in cucumber report. I'm using typescript language. Please anyone help me.

@Raghunandanr76
Copy link

Please confirm if there would be cucumber+Protractor+Typescript compatibility issues going forward...as we plan use the combination for our implementations..

@arjunjh10
Copy link

@Rajazpandi
Do something like this in After

driver.takeScreenshot().then(data => {
        attach(new Buffer(data, 'base64'), 'image/png');
      }).catch(error => {
        info(error);
        throw error;
      });

@lock
Copy link

lock bot commented Oct 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests