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

Using ts-jest together with ts-transformer-keys #303

Closed
golddranks opened this issue Aug 28, 2017 · 3 comments
Closed

Using ts-jest together with ts-transformer-keys #303

golddranks opened this issue Aug 28, 2017 · 3 comments

Comments

@golddranks
Copy link

Is it possible to use ts-jest together with custom transformers such as ts-transformer-keys? I'd like to do assertions of my data types in my tests to ensure that they are up to date with some backend data types. That's why I'd like to use ts-transformer-keys together with Jest. Is there any reasonable way to do it?

@kulshekhar
Copy link
Owner

A quick look tells me that ts-transformer-keys can be imported and used like any other javascript package. If this understanding is correct then there's no reason for this to not work. It will be treated and processed like any other javascript package.

Does that answer the question?

@DorianGrey
Copy link
Contributor

DorianGrey commented Aug 29, 2017

@golddranks is talking about custom transformers, which (currently) can only be used when accessing the compiler API directly. The docs of this one illustrate this:

https://github.com/kimamula/ts-transformer-keys#how-to-use-the-custom-transformer

In case of the transpileModule function ts-jest utilizes, custom transformers would have to be provided to the second argument transpileOptions on the key transformers, which gets forwarded to program.emit:
https://github.com/Microsoft/TypeScript/blob/ceae613e4c0ba36829a2381687883ecdc6b169c3/src/services/transpile.ts#L107
Unfortunately, this transformer requires access to the program instance, which is inaccessible from the outside when using transpileModule. Thus, supporting this feature - in its current state - is not possible without quite a large change on how modules are processed by ts-jest (i.e. replicating a lot of transpileModule's implementation).

@GeeWee
Copy link
Collaborator

GeeWee commented Sep 27, 2017

I'm closing this due to inactivity - it doesn't seem like something we'd support in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants