DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 671 forks source link

Add support for TypeScript configuration file #7373

Closed Halllker closed 1 month ago

Halllker commented 1 year ago

What is your Scenario?

TestCafe with TypeScript is so far a great experience, however there is an issue with global hooks and configuration file.

Global hooks can be defined only with JS configuration file which restricts from importing TypeScript classes and functions. This makes global hooks nearly impossible to use without some solid dark magic.

What are you suggesting?

Please, add a support for TypeScript configuration file so TS code can be referenced in global hooks and similar functionality (if any).

What alternatives have you considered?

Other possibility would be to separate global hooks from configuration files completely, which would maybe feel a bit more natural and there would be no need for js or ts config files and everything necessary could be handled by simple json.

Additional context

No response

Halllker commented 1 year ago

And of course right after I've created this issue I stumbled upon similar one that approaches basically the same problem from the other side. https://github.com/DevExpress/testcafe/issues/6867

Aleksey28 commented 1 year ago

Hi @Halllker,

Thank you for the suggestion. We'll update this thread once we have any news.

gforepsly commented 1 year ago

This enhancement would be great! I had similiar issues so I just went with .testcaferc.json for the configuration, and I created my own re-usable classes to handle repeating stuff. This would solve many issues for sure, thumbs up!

Jackman3005 commented 8 months ago

While we wait for the exciting PR to get merged. Is there a type annotation I can add in a comment in the .testcaferc.js file to get some type support for configuration options. Most tools I use support typescript config files and I immediately miss type support for exploring configuration options (and validating them) and am a little annoyed by having to visit the documentation every time I want to tweak or add something.

I tried looking through the source code to find a type definition for the config file contents, but I am not actually sure that one exists at this point...

Klaster1 commented 8 months ago

@Jackman3005 this works for me:

/** @type {TestCafeConfigurationOptions} */
module.exports = {
github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

github-actions[bot] commented 1 month ago

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.