Open lonix1 opened 5 years ago
Hey @dsherret, it appears I'm the only one using this combination of libraries, so I'd like to ask a quick "theoretical" question before I close this.
This library adds to the astTransformers
array, and I assume it plays nice with other transformers. So I thought the problem was with the jest-preset-angular
library, and asked about it there, though I've confirmed that library works in a multi-transformer setup without problem.
So there's a limitation in ts-jest
or ts-nameof
that prevents multiple transformers at the same time, or, a config problem (and ts+jest+angular config is notoriously brittle, so I'm guessing it's that).
So in summary: have you ever managed to get your library working together with other ast transformers, at the same time?
Based on briefly looking at this, it seems that ts-jest will actually provide its own compiler to the factory function. I didn't find this documentation until now and previously I was looking through the source code to try to figure this out:
So it's possible that ts-nameof for jest is using a different version of the compiler. If it were, then the syntax kind values would be different and there would be unexpected errors.
I'll have to make some changes to this in order to use that compilerModule
property.
@lonix1 Actually, this might not be the issue in this case if it works on its own. I'll open up a separate bug for that later. Have you tried changing the order of the transforms? Does using require.resolve
for ts-nameof work?
FWIW, I don't see anything wrong in InlineHtmlStripStylesTransformer
. Perhaps it's an issue with ts-jest.
I tried many things, like:
require.resolve
In all cases the jest-angular stuffs works, but nameof fails. But if I use nameof alone it works brilliantly.
I think you're right it's a problem with ts-jest. Please don't do anything about this as because you don't use angular, so I don't want you to waste your time. I see there are quite a few angular users besides me, so hopefully one of them will join this issue with some ideas!
Should I go ahead and close?
The compiler never listens to my prayers either 😞
No, it's fine—keep it open. I'll look into it eventually.
Also, opened #52.
Has anyone used this library in a monorepo project with the jest-preset-angular preset, which configures
ts-jest
in a way that conflicts with this library.I tried this which doesn't work (nameof is detected, but then the preset fails and so the tests don't run):
In fact is it even possible to use multiple presets or transformers?