mirror of https://github.com/facebook/jest.git
chore: do not string replace with self in test (#14588)
This commit is contained in:
parent
5aeee2efc5
commit
85278ee979
|
@ -76,16 +76,14 @@ jest
|
|||
jest.mock(
|
||||
'test_preprocessor',
|
||||
() => {
|
||||
const escapeStrings = (str: string) => str.replace(/'/, "'");
|
||||
|
||||
const transformer: Transformer = {
|
||||
getCacheKey: jest.fn(() => 'ab'),
|
||||
process: (content, filename, config) => ({
|
||||
code: (require('dedent') as typeof import('dedent').default)`
|
||||
const TRANSFORMED = {
|
||||
filename: '${escapeStrings(filename)}',
|
||||
script: '${escapeStrings(content)}',
|
||||
config: '${escapeStrings(JSON.stringify(config))}',
|
||||
filename: '${filename}',
|
||||
script: '${content}',
|
||||
config: '${JSON.stringify(config)}',
|
||||
};
|
||||
`,
|
||||
}),
|
||||
|
@ -99,17 +97,15 @@ jest.mock(
|
|||
jest.mock(
|
||||
'test_async_preprocessor',
|
||||
() => {
|
||||
const escapeStrings = (str: string) => str.replace(/'/, "'");
|
||||
|
||||
const transformer: AsyncTransformer = {
|
||||
getCacheKeyAsync: jest.fn(() => Promise.resolve('ab')),
|
||||
processAsync: (content, filename, config) =>
|
||||
Promise.resolve({
|
||||
code: (require('dedent') as typeof import('dedent').default)`
|
||||
const TRANSFORMED = {
|
||||
filename: '${escapeStrings(filename)}',
|
||||
script: '${escapeStrings(content)}',
|
||||
config: '${escapeStrings(JSON.stringify(config))}',
|
||||
filename: '${filename}',
|
||||
script: '${content}',
|
||||
config: '${JSON.stringify(config)}',
|
||||
};
|
||||
`,
|
||||
}),
|
||||
|
|
Loading…
Reference in New Issue