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

[Bug]: Default transform regex does not escape dot properly #4579

Closed
nikwen opened this issue Oct 8, 2024 · 2 comments · Fixed by #4698
Closed

[Bug]: Default transform regex does not escape dot properly #4579

nikwen opened this issue Oct 8, 2024 · 2 comments · Fixed by #4698
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@nikwen
Copy link

nikwen commented Oct 8, 2024

Version

29.7.0

Steps to reproduce

  1. npm i -D jest typescript ts-jest @types/jest
  2. npx ts-jest config:init

Expected behavior

Regex in jest.config.js escapes dot properly, e.g. '^.+\\.tsx?$'.

Actual behavior

Regex is not escaped properly: '^.+.tsx?$'

Regexes are defined here:

export const TS_TRANSFORM_PATTERN = '^.+.tsx?$'
export const ESM_TS_TRANSFORM_PATTERN = '^.+\\.m?tsx?$'
export const TS_JS_TRANSFORM_PATTERN = '^.+.[tj]sx?$'
export const ESM_TS_JS_TRANSFORM_PATTERN = '^.+\\.m?[tj]sx?$'
export const JS_TRANSFORM_PATTERN = '^.+.jsx?$'
export const ESM_JS_TRANSFORM_PATTERN = '^.+\\.m?jsx?$'

Debug log

Irrelevant for this issue

Additional context

No response

Environment

System:
    OS: macOS 14.7
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 20.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.8.1 - /usr/local/bin/npm
  npmPackages:
    jest: 29.7.0 => 29.7.0
@YukiBobier
Copy link

@nikwen

I noticed the same issue. The regex should properly escape dots.

ahnpnl added a commit that referenced this issue Feb 22, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fixes #4579
ahnpnl added a commit that referenced this issue Feb 22, 2025

Verified

This commit was signed with the committer’s verified signature.
theoludwig Théo LUDWIG
Fixes #4579
@nikwen
Copy link
Author

nikwen commented Feb 23, 2025

Thanks, @ahnpnl!

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

Successfully merging a pull request may close this issue.

3 participants