Skip to content

Commit

Permalink
fix: escape dot for TS_TRANSFORM_PATTERN regex
Browse files Browse the repository at this point in the history
Fixes #4579
  • Loading branch information
ahnpnl committed Feb 22, 2025
1 parent 4811d42 commit 80d3e4d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
28 changes: 14 additions & 14 deletions src/cli/__snapshots__/cli.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`config init should create a jest config file with cli options for confi
module.exports = {
testEnvironment: "node",
transform: {
"^.+.tsx?$": ["ts-jest",{}],
"^.+\\.tsx?$": ["ts-jest",{}],
},
};"
`;
Expand All @@ -15,7 +15,7 @@ exports[`config init should create a jest config file with cli options for confi
export default {
testEnvironment: "node",
transform: {
"^.+.tsx?$": ["ts-jest",{}],
"^.+\\.tsx?$": ["ts-jest",{}],
},
};"
`;
Expand Down Expand Up @@ -66,7 +66,7 @@ exports[`config init should update package.json for config type default when use
"version": "0.0.0-mock.0",
"jest": {
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -82,7 +82,7 @@ exports[`config init should update package.json for config type js-with-babel-fu
"jest": {
"transform": {
"^.+.jsx?$": "babel-jest",
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.test.json"
Expand Down Expand Up @@ -114,7 +114,7 @@ exports[`config migrate should generate transform config with existing transform
"module.exports = {
transform: {
'^.+.jsx?$': 'babel-jest',
'^.+.tsx?$': [
'^.+\\\\.tsx?$': [
'ts-jest',
{},
],
Expand All @@ -130,7 +130,7 @@ exports[`config migrate should generate transform config with existing transform
'ts-jest',
{},
],
'^.+.tsx?$': [
'^.+\\\\.tsx?$': [
'ts-jest',
{},
],
Expand All @@ -142,7 +142,7 @@ exports[`config migrate should generate transform config with existing transform
exports[`config migrate should migrate preset if valid preset value is used 1`] = `
""jest": {
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -154,7 +154,7 @@ exports[`config migrate should migrate preset if valid preset value is used 1`]
exports[`config migrate should migrate preset if valid preset value is used 2`] = `
""jest": {
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -166,7 +166,7 @@ exports[`config migrate should migrate preset if valid preset value is used 2`]
exports[`config migrate should migrate preset if valid preset value is used 3`] = `
""jest": {
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -179,7 +179,7 @@ exports[`config migrate should reset testMatch if testRegex is used 1`] = `
""jest": {
"testRegex": "foo-pattern",
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -194,7 +194,7 @@ exports[`config migrate should reset testMatch if testRegex is used 2`] = `
"foo-pattern"
],
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -210,7 +210,7 @@ exports[`config migrate should reset testMatch if testRegex is used 3`] = `
"**/__tests__/**/*.(spec|test).[tj]s?(x)"
],
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -225,7 +225,7 @@ exports[`config migrate should reset testMatch if testRegex is used 4`] = `
"**/__tests__/**/*.(spec|test).[tj]s?(x)"
],
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand All @@ -238,7 +238,7 @@ exports[`config migrate should reset testMatch if testRegex is used 5`] = `
""jest": {
"testRegex": "foo-pattern",
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand Down
10 changes: 5 additions & 5 deletions src/cli/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe('config', () => {
",
"stdout": ""jest": {
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{
"tsconfig": {
Expand Down Expand Up @@ -386,7 +386,7 @@ describe('config', () => {
"**/__tests__/**/*.ts?(x)"
],
"transform": {
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{
"tsconfig": {
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('config', () => {
expect(res.stdout).toMatchInlineSnapshot(`
"module.exports = {
transform: {
'^.+.tsx?$': [
'^.+\\\\.tsx?$': [
'ts-jest',
{},
],
Expand Down Expand Up @@ -556,7 +556,7 @@ describe('config', () => {
'ts-jest',
{},
],
'^.+.tsx?$': [
'^.+\\\\.tsx?$': [
'ts-jest',
{},
],
Expand Down Expand Up @@ -600,7 +600,7 @@ describe('config', () => {
"ts-jest",
{}
],
"^.+.tsx?$": [
"^.+\\\\.tsx?$": [
"ts-jest",
{}
]
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const DECLARATION_TYPE_EXT = '.d.ts'
export const JS_JSX_EXTENSIONS = ['.js', '.jsx']
export const TS_TSX_REGEX = /\.[cm]?tsx?$/
export const JS_JSX_REGEX = /\.[cm]?jsx?$/
export const TS_TRANSFORM_PATTERN = '^.+.tsx?$'
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?$'
Expand Down
8 changes: 4 additions & 4 deletions src/presets/__snapshots__/create-jest-preset.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`create-jest-preset CJS presets createDefaultLegacyPreset should return preset config 1`] = `
{
"transform": {
"^.+.tsx?$": [
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.spec.json",
Expand All @@ -16,7 +16,7 @@ exports[`create-jest-preset CJS presets createDefaultLegacyPreset should return
exports[`create-jest-preset CJS presets createDefaultPreset should return preset config 1`] = `
{
"transform": {
"^.+.tsx?$": [
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.spec.json",
Expand All @@ -30,7 +30,7 @@ exports[`create-jest-preset CJS presets createJsWithBabelLegacyPreset should ret
{
"transform": {
"^.+.jsx?$": "babel-jest",
"^.+.tsx?$": [
"^.+\\.tsx?$": [
"ts-jest/legacy",
{
"babelConfig": {
Expand All @@ -47,7 +47,7 @@ exports[`create-jest-preset CJS presets createJsWithBabelPreset should return pr
{
"transform": {
"^.+.jsx?$": "babel-jest",
"^.+.tsx?$": [
"^.+\\.tsx?$": [
"ts-jest",
{
"babelConfig": {
Expand Down

0 comments on commit 80d3e4d

Please sign in to comment.