kulshekhar / ts-jest

A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.
https://kulshekhar.github.io/ts-jest
MIT License
6.95k stars 452 forks source link

[Bug]: Exported enums not working on tests #3397

Open ibesora opened 2 years ago

ibesora commented 2 years ago

Version

27.1.4

Steps to reproduce

Expected behavior

Tests should pass

Actual behavior

Tests fail with TypeError: Cannot read property 'Above' of undefined

Debug log

See it here It was too long to add it here

Additional context

It seems to be a regression of https://github.com/kulshekhar/ts-jest/issues/281 I can update the protomaps package if needed but it doesn't look like it's doing anything weird Setting isolatedModules to false doesn't change anything

Environment

System:
    OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11980HK @ 2.60GHz
  Binaries:
    Node: 16.8.0 - ~/.asdf/installs/nodejs/16.8.0/bin/node
    Yarn: 1.22.15 - ~/.asdf/installs/nodejs/16.8.0/.npm/bin/yarn
    npm: 7.21.0 - ~/.asdf/plugins/nodejs/shims/npm
  npmPackages:
    jest: ^27.5.1 => 27.5.1
ibesora commented 2 years ago

Hi, any update on this?

ahnpnl commented 2 years ago

We just noticed this while working on Jest 28 support, will try to fix this issue.

ibesora commented 2 years ago

Any update on this? Can't test an important part of our app without this. Thanks!

kudryashov13 commented 2 years ago

Also facing the same issue, hope it will be fixed soon.

OxyFlax commented 2 years ago

@ibesora @kudryashov13 In case you didn't see, a way to tackle the issue while it's being fixed has been found here https://github.com/kulshekhar/ts-jest/issues/281#issuecomment-500780488

mikerentmeister commented 2 years ago

Please fix this, it's affecting our core testing functionality

edwardfranco7 commented 2 years ago

Hey, any update on this one? I can confirm tests still fail using ts-jest v28.0.8 with jest v28.0.3 and v28.1.3. Thank you!

JoaquinEduardoArreguez commented 2 years ago

I am facing the same problem on version 28.0.1, @ahnpnl is there any update on this?

Smrtnyk commented 2 years ago

the protomaps does not do preserveContEnums in the tsconfig, so it is not preserved in the transpiled output you can't import something that is not there

ibesora commented 2 years ago

the protomaps does not do preserveContEnums in the tsconfig, so it is not preserved in the transpiled output you can't import something that is not there

That doesn't seem to make a difference at all.

PrashanthRyada commented 2 years ago

Hey, any update on this?

honghainguyen777 commented 2 years ago

I'm having the same problem. It could be a Circular imports issue. However, I am still trying my test to find or come up with a solution.

rkuykendall commented 1 year ago

https://github.com/kulshekhar/ts-jest/pull/308/files

chce commented 1 year ago

I've had success mocking the enum and returning an object instead.

obrejla commented 5 months ago

Hi guys, this is still problem...any news when it will be fixed?

"jest": "29.7.0", "ts-jest": "29.1.2",

redplane commented 4 months ago

I've had success mocking the enum and returning an object instead.

Can you show your solution ? I'm having this frustrating issue too.