Open Faithfinder opened 2 years ago
With
ts-jest
/babel
approach it's not a problem since transformers are applied to setup files as well, however withheft
you need to link actual JS files.
Is the problem that Heft's Jest plugin tries to load the .js
file /before/ TypeScript has compiled it? We could probably change that.
I think I have the same problem mentioned here.
If you create a file
jest-build-transform: The input path is not under the "src" folder:
Summary
Sometimes, building non-source files is needed, and heft's support for that is poor.
Details
While
heft
's model of "Use the same code you build" works quite well for library/application code, sometimes that's not the only typescript files in the package that you want to use.The main use case that I have in mind and is sort of a blocker is
jest
setup files. They are extremely useful for integration/system level testing, and I want to use typescript to write them. Withts-jest
/babel
approach it's not a problem since transformers are applied to setup files as well, however withheft
you need to link actual JS files. This creates two problems.1)
jest.config
needs to reference the built file instead of the source file, which can be unintuitive. 2) You're unable to keep you setup files in a separate folder fromsrc
(e.gscripts
) (and I don't want thing like that insrc
).This is the case that I've actually hit and hinders me from using
heft test
in one of the apps - I need a setup file. I'll probably end up putting the setup script insrc
after all (when Jest 27 gets merged since I also need that), but my soul will ache when I do this.However, I also have theoretical reservation about similar cases:
src
altogether and have atests
folder at the same level instead. In a monorepo I'd probably just make a@scope/tests-projectname
package at this point, but heft ain't only for monoreposdeploy
or customprebuild
that I don't want insrc
and prefer to keep inscripts
instead. I think these would usually be shell scripts instead, but I don't discard the idea that I'd want some in Typescript. Same clause about monorepo as above.