-
Notifications
You must be signed in to change notification settings - Fork 673
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
[TypeScript] Add capability to specify the custom module path mapping mechanism (specified by the paths and baseUrl options) #4144
Comments
At present, we use the standard Node.js module resolving mechanism for all test types ( |
Well that's surprising, given in that it states in the CHANGELOG that it is:
An example is even provided! |
We will fix Changelog and documentation. |
Also was discussed on StackOverflow: https://stackoverflow.com/questions/57014497/how-to-resolve-non-relative-paths-with-testcafe-when-using-typescript TypeScript doesn't substitute real module paths for mapped module paths, see this comment and thread for an explanation:
The tsconfig-path module can resolve mapped module paths at runtime. I think TestCafe should load it automatically. As a workaround, you can install
|
Hey @AndreyBelym Do you know a way to require |
Hi @pupudu, You can use |
Hi @alexey-lin Thanks for your suggestion mate, that worked well. I also found just after, that simply starting the server with |
@AlexKamaev This is not an enhancement, rather a bug. TestCafe documentation explicitly states this behaviour is supported but it is not: |
It is a bit sad that this is "fixed" by updating the doc like that. I am a testcafe poweruser (I use it in many projects, I teach about it to big companies and I speak at conferences as well). I am reaching a point where I can't defend it anymore against Cypress. I love testcafe, I really do, but stuff like this is a step back. In Angular world, we use a tool called "Nx" to create workspaces. Workspaces are composed by many different projects and libraries. The way we communicate with those projects and libraries is using this It is not like you import lots of projects things within testcafé, but sometimes I need an interface or an enumeration and this makes it complicated. Honestly I am unsure how hard is this to fix, but typescript is getting bigger every day and we need testcafe to follow the path. |
@Foxandxss It would be nice if testcafe supported |
I think i missed that extra flag you mention.
El mié., 11 nov. 2020 9:27, Pubudu Dodangoda <[email protected]>
escribió:
… @Foxandxss <https://github.com/Foxandxss> It would be nice if testcafe
supported out of the box indeed.
But honestly, I don't see a big issue in using tsconfig-paths using the
extra flag. Works great to the date in my case. Did you find any issues
with that approach?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIJTVLMBTLHSL3SBNEQNALSPJDG7ANCNFSM4ILKXEWA>
.
|
The suggested solutions with tsconfig-paths do not work for me.
I am having a project with one src and one testcafe directory and I am trying to import
The tsconfig.test.json just extends the tsconfig.json with a different baseUrls.
Still do I get the following error when running the tests:
Any idea how I can debug this further? |
@reh2ur Have you tried importing the module instead? i.e. on the top of your entry point, import 'tsconfig-paths/register'; |
Is there a way to do this globally so we don't have to import "tsconfig-paths/register" in each test? |
Could you please share the whole |
And make sure .testcaferc.json has:
|
FYI you can add |
I've tried all of the above in our project and couldn't get this to work. Does anyone have a working example in an open source repo I could check out? |
What is your Test Scenario?
Using Testcafe version: 1.4.0
Following the documentation here: https://devexpress.github.io/testcafe/documentation/test-api/typescript-support.html
I created a typescript config file in the root of my project with the following:
I added a reference to the tsConfigPath in the .testcaferc:
In my test file I added the following import:
import { annotateTestOutput,visualValidation } from 'helpers';
What is the Current behavior?
When I run testcafe I get the following error:
What is the Expected behavior?
The module should resolve using the paths defined in the tsconfig file.
I know the tsconfig file is being found and parsed because if I add, for example, module or target settings I get the testcafe warning about not being able to override those settings.
Your Environment details:
The text was updated successfully, but these errors were encountered: