Skip to content

test: transpile ESM-only cookie@2 in jest suite - #536

Merged
Tony133 merged 2 commits into
mainfrom
fix/jest-cookie-esm
Oct 28, 2026
Merged

Tony133 merged 2 commits into
mainfrom
fix/jest-cookie-esm

Conversation

@Tony133

@Tony133 Tony133 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Proposal:

[email protected] bumped cookie to 2.x, which is ESM-only. The typescript-jest suite runs in CommonJS through ts-jest, so Jest can no longer require() cookie/dist/index.js and every app.inject() call fails:

https://github.com/fastify/fastify-autoload/actions/runs/40437079305/job/122488466342?pr=535#step:5:88

The failure only shows up on a fresh install (no lockfile in the repo), which is why it appeared on CI before local environments with an older node_modules.

Changes:

  • Add transformIgnorePatterns so cookie is no longer skipped by the transform
  • Extend the ts-jest transform to .js with allowJs: true so cookie is compiled to CJS

The exception is scoped to cookie/ only; the rest of node_modules is still ignored. Works on every Node version in the CI matrix, independent of Jest's native require(esm) support.

@Tony133
Tony133 marked this pull request as ready for review October 27, 2026 22:06
@Tony133
Tony133 requested a review from a team October 27, 2026 22:06

@ilteoood ilteoood left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worth to move these settings in their own jest.config.js file, so that we can avoid bloating the package.json

@Tony133

Tony133 commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

I think it would be worth to move these settings in their own jest.config.js file, so that we can avoid bloating the package.json

Done, moved to jest.config.js to match vitest.config.ts, and removed the jest key from package.json. See commit 28315e6.

@Tony133
Tony133 requested a review from ilteoood October 28, 2026 14:52
@Tony133
Tony133 merged commit 66bc419 into main Oct 28, 2026
22 checks passed
@Tony133
Tony133 deleted the fix/jest-cookie-esm branch October 28, 2026 15:48
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 this pull request may close these issues.

2 participants