GoogleFeud / ts-runtime-checks

A typescript transformer that automatically generates validation code from your types.
https://googlefeud.github.io/ts-runtime-checks/
MIT License
312 stars 7 forks source link

[FEATURE] tests with jest #49

Closed dyushin closed 11 months ago

dyushin commented 11 months ago

Hello!

I want to run the tests with jest, but encountered an error

TypeError: (0 , ts_runtime_checks_1.check) is not a function or its return value is not iterable I can't combine ts-jest with tspc

Is there any way to combine them?

dyushin commented 11 months ago

Found solution

just change compiler in jest.config file

module.exports = {
    globals: {
        "ts-jest": {
            compiler: "ts-patch/compiler",
        },
    },
dotnich-io commented 10 months ago

@dyushin do you know why that works, and can you explain that to me please?

dyushin commented 10 months ago

@dyushin do you know why that works, and can you explain that to me please?

I don't know exactly how. But it seems that, as in the case of the ts-runtime-checks library itself, the code is compiled by a modified ts-patch before running the tests