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

Support custom TypeScript compiler options #1845

Closed
Hotell opened this issue Oct 5, 2017 · 26 comments
Closed

Support custom TypeScript compiler options #1845

Hotell opened this issue Oct 5, 2017 · 26 comments
Assignees
Labels
AREA: server HELP WANTED !IMPORTANT! STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: compiler TYPE: enhancement The accepted proposal for future implementation.
Milestone

Comments

@Hotell
Copy link

Hotell commented Oct 5, 2017

Are you requesting a feature or reporting a bug?

feature

What is the suggested behavior?

TestCafe should provide a way to modify TypeScript compilation options for test files. For instance, there should be an option that enables JSX compilation:

"jsx": "react"

Additional Details

Current behavior if I wanna import something to test file from file that has an `tsx` extension f.e.: `foo.tsx` file, testcafe TS compilation will error out:

testcafe chrome e2e/test.ts

image

System information
  • operating system: OSX
  • testcafe version: testcafe@0.17.2
  • node.js version: v8.6.0
@AlexanderMoskovkin AlexanderMoskovkin added AREA: server SYSTEM: compiler TYPE: enhancement The accepted proposal for future implementation. labels Oct 6, 2017
@AlexanderMoskovkin
Copy link
Contributor

Hi @Hotell,

Thanks for the proposal, we'll investigate.
As always PR is welcome.

@Hotell
Copy link
Author

Hotell commented Oct 6, 2017

ok so this won't work, what really needs to be done is to allow testcafe to consume users tsconfig.json

In our case we are using preact with aliases to React typings, so we also need to set jsxFactory: h instead of React standard -> jsxFactory: createElement and many other custom config for path aliasing

@Hotell
Copy link
Author

Hotell commented Oct 6, 2017

So I've been tweaking testcafe source a bit and come up with something like this for getting needed tsconfig settings from user's tsconfig

https://gist.github.com/Hotell/f88c7588d6e878df87fe01f12019de1f#file-compiler-js-L2-L41

which is almost working , just have to resolve few issues with path mapping

I still got some errors

image

@AlexanderMoskovkin AlexanderMoskovkin added this to the Planned milestone Oct 9, 2017
@AlexanderMoskovkin
Copy link
Contributor

@Hotell, thanks for you investigations. I suppose it can be some conflicts between TestCafe TypeScript settings and a custom tsconfig.

Meanwhile, I think it would be nice to add an ability to pass a custom tsconfig file path to TestCafe run.

@Hotell
Copy link
Author

Hotell commented Oct 9, 2017

Meanwhile, I think it would be nice to add an ability to pass a custom tsconfig file path to TestCafe run.

working on it, will send PR when ready ;)

@miherlosev
Copy link
Collaborator

There is a more one use case:
I want to use JQuery in ClientFunction.

var getElementHeigth = ClientFunction(() => { $(element()).heigth(); }, { dependencies: element});

Then I run TestCafe, I get an error message Cannot find name $.

In this way, I need a way to extend tsconfig used by testcafe for compiling tests.

@andrewbranch
Copy link
Contributor

andrewbranch commented Jan 23, 2018

This is pretty crucial for us as well. We have typings that would be nice to access in ClientFunctions, and they can't be imported from within TestCafe because we use path aliases and decorators in our client code, which aren't compatible with the compiler options TestCafe has hard-coded. Any progress here?

@AlexanderMoskovkin
Copy link
Contributor

Thanks for your point. Actually we didn't work on this yet but it's in our plans.

@ahnpnl
Copy link

ahnpnl commented Feb 26, 2018

Hi @AlexanderMoskovkin, are there any workarounds for now to let testcafe read a custom tsconfig ?

@AlexanderMoskovkin
Copy link
Contributor

Hi @AhnpGit,

Sorry for late response. Unfortunately I don't see workarounds here for now. But this feature is in our plans and we'll implement it in future (can't provide estimates for now).

@nzav
Copy link

nzav commented Apr 15, 2018

Need that feature as well to add custom paths aliases to tsconfig.

@miherlosev miherlosev modified the milestones: Planned, Sprint #16 Aug 14, 2018
@AndreyBelym AndreyBelym modified the milestones: Sprint #16, Sprint #17 Aug 14, 2018
@AndreyBelym AndreyBelym modified the milestones: Sprint #17, Planned Aug 30, 2018
@Foxandxss
Copy link

No workaround for this right now? If I import code from my app (to use in tests) and that uses this feature, it fails.

@AndreyBelym
Copy link
Contributor

@Foxandxss, unfortunately you have to compile you app to the plain JS before importing its code from TestCafe test files.

@Foxandxss
Copy link

That is problematic.

We have a complex Angular app using stuff like:

import { Foo } from `@core/foo/bar`

So if we try to import from testcafé any angular file (any at all) it will try to compile the entire app and fail because it won't recognize the syntax.

@dapperdandev
Copy link

dapperdandev commented Sep 26, 2018

Hi @Foxandxss!

Is there a specific reason that you have your testcafe code and your angular code in the same project? I believe the idea is that your testcafe tests exist in their own project and you run them against a served up or deployed app. I'd recommend separating your testcafe tests from your angular app.

Forgive me if I'm confused. :) Maybe there are some unseen benefits to your approach. It just seems uncommon to me.

Regardless, I'm specifically subscribed to this thread in hopes that this feature will be implemented soon. Looks like it's getting there.

@AndreyBelym AndreyBelym removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 20, 2019
@Hotell
Copy link
Author

Hotell commented Mar 21, 2019

@icfantv nope. Unfortunately I had other priorities...

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 21, 2019
@AndreyBelym AndreyBelym removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 22, 2019
@parekhkb
Copy link

In order to help keep our E2E test suite sturdy, we want to have our React components define their own test selectors. So we would like our react TSX files to declare static string properties called testSelector, which our TestCafe fixtures would then import. The hope is to break at compilation time if a developer refactors code which removes used test selectors.

In order to do this we need to configure TestCafe to compile JSX.

Please consider this feature for 2019.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 23, 2019
@miherlosev miherlosev removed the STATE: Need response An issue that requires a response or attention from the team. label May 24, 2019
@rodmax
Copy link

rodmax commented May 31, 2019

Hi guys... really needed feature to set tsconfig's paths to share typings of API data between app and e2e test, to sync mocks of http data

could someone please point me about status a little more specifically in terms of dates, for example:

"we planning active investigate & implement it this summer 2019"

or

"we are unlikely to do this before winter"

This answer helps me decide on the choice of technology to my active projects

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 31, 2019
@rbardini
Copy link
Contributor

I second that—our entire codebase is written in .tsx files, and this prevents us from reusing existing typings in E2E tests.

Would it be possible to enable JSX with react mode in the default TestCafe TypeScript settings? I understand this would not fully solve the issue, since different projects have different needs, but it would already cover a lot of common use cases until we have proper support for custom settings.

@aleks-pro aleks-pro self-assigned this Jun 3, 2019
@aleks-pro
Copy link
Collaborator

Hi guys... really needed feature to set tsconfig's paths to share typings of API data between app and e2e test, to sync mocks of http data

could someone please point me about status a little more specifically in terms of dates, for example:

"we planning active investigate & implement it this summer 2019"

or

"we are unlikely to do this before winter"

This answer helps me decide on the choice of technology to my active projects

Hello @rodmax,

At the moment we are not working on this feature, but we have it in our roadmap for 2019. I cannot give you more precise estimate right now.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 3, 2019
@aleks-pro
Copy link
Collaborator

I second that—our entire codebase is written in .tsx files, and this prevents us from reusing existing typings in E2E tests.

Would it be possible to enable JSX with react mode in the default TestCafe TypeScript settings? I understand this would not fully solve the issue, since different projects have different needs, but it would already cover a lot of common use cases until we have proper support for custom settings.

Hello @rbardini ,

Thank you for the idea. We will take your suggestion into account when we are ready to implement this feature.

@AndreyBelym AndreyBelym modified the milestones: Planned, Sprint #34 Jun 4, 2019
@AndreyBelym AndreyBelym assigned AlexKamaev and unassigned aleks-pro Jun 4, 2019
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Jun 10, 2019
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Jun 10, 2019
@AndreyBelym AndreyBelym modified the milestones: Sprint #34, Sprint #35 Jun 17, 2019
Enhancements processing automation moved this from Compiler suggestions to Closed Jun 17, 2019
@lock
Copy link

lock bot commented Jun 27, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Jun 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 27, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server HELP WANTED !IMPORTANT! STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: compiler TYPE: enhancement The accepted proposal for future implementation.
Projects
No open projects
Development

No branches or pull requests