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

Add support for Jest 27 #2611

Closed
ayuhito opened this issue May 25, 2021 · 17 comments
Closed

Add support for Jest 27 #2611

ayuhito opened this issue May 25, 2021 · 17 comments
Labels
🚀 Feature Request new suggested feature

Comments

@ayuhito
Copy link

ayuhito commented May 25, 2021

🐛 Bug Report

Upgrading to Jest 27 leads to the following error:
TypeError: Jest: a transform must export something.

Also the peer dependency scope should be updated alongside this fix:
warning " > [email protected]" has incorrect peer dependency "jest@>=26 <27".

To Reproduce

Upgrade from Jest 26 to Jest 27.

Expected behavior

Running the jest command to successfully run tests.

Debug log:

# content of ts-jest.log :
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"26.5.6"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2021-05-25T10:57:05.252Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"26.5.6"},"message":"creating jest presets not handling JavaScript files","sequence":2,"time":"2021-05-25T10:57:05.265Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"26.5.6"},"message":"creating Importer singleton","sequence":3,"time":"2021-05-25T10:57:05.980Z"}

envinfo

System:
    OS: Windows 10
    Node version: 15.12.0

Npm packages:
    "jest": "^27.0.1",
    "ts-jest": "^26.5.6",
    "typescript": "^4.2.4"
@ayuhito ayuhito added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels May 25, 2021
@ahnpnl
Copy link
Collaborator

ahnpnl commented May 25, 2021

Thanks for notification, we already prepare for it at next tag so we will prepare for latest tag soon.

@ahnpnl ahnpnl closed this as completed May 25, 2021
@ahnpnl ahnpnl added 🚀 Feature Request new suggested feature and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels May 25, 2021
@ahnpnl ahnpnl added this to the ts-jest v27 milestone May 25, 2021
@ahnpnl ahnpnl pinned this issue May 25, 2021
@brettdorrans
Copy link

@ahnpnl Can you give some indication of when soon is? Also, it would be helpful to keep this issue open while the problem exists, I had assumed it was resolved given you'd closed it.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 25, 2021

it is resolved in next tag. If you are in a hurry, you can use ts-jest@next. next tag is basically ready to release.

@brettdorrans
Copy link

Ideal, thank you.

@mishakorablin
Copy link

@ahnpnl, looks like npm still points next to 27.0.0-next.12, which was published awhile back. It currently supports jest until 27.0.0-next9. However, latest jest release is 27.0.1

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 25, 2021

next tag is fully compatible despite the warning message. You can temporarily use next tag if you are in a hurry :) ts-jest 27 will be released within this week.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 25, 2021

27.0.0 was out

@ahnpnl ahnpnl unpinned this issue May 25, 2021
@sauldeleon
Copy link

Hello, I am having this issue in 27.0.1

image

    "ts-jest": "27.0.1"

It is related with this?

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 30, 2021

Please clear Jest cache.

Also check your lock file to make sure ts-jest is 27.0.1

You can also remove node_modules and reinstall deps.

@sauldeleon
Copy link

sauldeleon commented May 30, 2021

Thanks @ahnpnl for your (I must say) incredibly fast response.

I have:

  • Cleared jest cache doing jest --showConfig | grep "cache" and removed all cache directories listed by the command, also runned jest --clearCache
  • removed node_modules
  • confirmed yarn.lock is 27.0.1

image

Unfortunately, error keeps there :(

I can provide a repo if needed

Edit: Testing repo here

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 30, 2021

You are using Jest 26 with ts-jest 27, which is not a valid combination, see https://github.com/sauldeleon/monorepo-starter/blob/623bc73b10f1a33f3f73695d96cf8c473c7aaedc/yarn.lock#L1744. ts-jest major version always follows Jest major version. For example: Jest 26 with ts-jest 26, Jest 27 with ts-jest 27

@sauldeleon
Copy link

sauldeleon commented May 30, 2021

thanks a lot @ahnpnl . As you said, this was the issue. Seems that CRA installs jest 26! Thanks a lot

EDIT: for whoever reaching this post, if you are using react-scripts 4.0.3 or below, it internally uses jest 26, so installing ts-jest 27 will crash everything.

You can force react-scripts to use jest 27 using yarn resolutions feature to force react-scripts to use jest 27, or wait until react-scripts updates internal dependency

@suvasishm
Copy link

suvasishm commented Aug 25, 2021

I am still facing the issue while upgrading jest and ts-jest to v27. Tried npx jest --clearCache.

"jest": "^27.0.6",
"ts-jest": "^27.0.5",
"@types/jest": "^27.0.1"

Using Windows 10 and

"engines": {
    "node": ">=14.16.1",
    "npm": ">=6.14.12"
}

@peterphan1996
Copy link

I'm having the same problem as @suvasishm

1 similar comment
@DanielUche
Copy link

I'm having the same problem as @suvasishm

@juanguren
Copy link

Hey everyone!
Following up on this thread, one basic question: How can I upgrade the versions of jest and @types/jest? (NPM)
I immediately assumed a npm i -D jest.. would do so automatically, but both versions remain at 26 and I need all of them to be at 27. I'm trying to solve this error -

image

I'd appreciate your help!

@juanguren
Copy link

Hey everyone!
Following up on this thread, one basic question: How can I upgrade the versions of jest and @types/jest? (NPM)
I immediately assumed a npm i -D jest.. would do so automatically, but both versions remain at 26 and I need all of them to be at 27. I'm trying to solve this error -

image

I'd appreciate your help!

I managed to solve it. Just run the npm install ts-jest@27 (npm install {package}@{version}) command. Applicable to any package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature Request new suggested feature
Projects
None yet
Development

No branches or pull requests

9 participants