Skip to content

Commit 85278ee

Browse files
authored
chore: do not string replace with self in test (#14588)
1 parent 5aeee2e commit 85278ee

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

packages/jest-transform/src/__tests__/ScriptTransformer.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,14 @@ jest
7676
jest.mock(
7777
'test_preprocessor',
7878
() => {
79-
const escapeStrings = (str: string) => str.replace(/'/, "'");
80-
8179
const transformer: Transformer = {
8280
getCacheKey: jest.fn(() => 'ab'),
8381
process: (content, filename, config) => ({
8482
code: (require('dedent') as typeof import('dedent').default)`
8583
const TRANSFORMED = {
86-
filename: '${escapeStrings(filename)}',
87-
script: '${escapeStrings(content)}',
88-
config: '${escapeStrings(JSON.stringify(config))}',
84+
filename: '${filename}',
85+
script: '${content}',
86+
config: '${JSON.stringify(config)}',
8987
};
9088
`,
9189
}),
@@ -99,17 +97,15 @@ jest.mock(
9997
jest.mock(
10098
'test_async_preprocessor',
10199
() => {
102-
const escapeStrings = (str: string) => str.replace(/'/, "'");
103-
104100
const transformer: AsyncTransformer = {
105101
getCacheKeyAsync: jest.fn(() => Promise.resolve('ab')),
106102
processAsync: (content, filename, config) =>
107103
Promise.resolve({
108104
code: (require('dedent') as typeof import('dedent').default)`
109105
const TRANSFORMED = {
110-
filename: '${escapeStrings(filename)}',
111-
script: '${escapeStrings(content)}',
112-
config: '${escapeStrings(JSON.stringify(config))}',
106+
filename: '${filename}',
107+
script: '${content}',
108+
config: '${JSON.stringify(config)}',
113109
};
114110
`,
115111
}),

0 commit comments

Comments
 (0)