diff --git a/packages/jest-each/src/__tests__/array.test.ts b/packages/jest-each/src/__tests__/array.test.ts index a7eb3e0e11f4..c70aa94e8d18 100644 --- a/packages/jest-each/src/__tests__/array.test.ts +++ b/packages/jest-each/src/__tests__/array.test.ts @@ -368,6 +368,52 @@ describe('jest-each', () => { undefined, ); }); + + test('calls global with title containing param values when using %#', () => { + const globalTestMocks = getGlobalTestMocks(); + const eachObject = each.withGlobal(globalTestMocks)([ + {name: 'foo'}, + {name: 'bar'}, + ]); + const testFunction = get(eachObject, keyPath); + testFunction('expected string: %#', () => {}); + + const globalMock = get(globalTestMocks, keyPath); + expect(globalMock).toHaveBeenCalledTimes(2); + expect(globalMock).toHaveBeenCalledWith( + 'expected string: foo 0', + expectFunction, + undefined, + ); + expect(globalMock).toHaveBeenCalledWith( + 'expected string: bar 1', + expectFunction, + undefined, + ); + }); + + test('calls global with title containing param values when using $#', () => { + const globalTestMocks = getGlobalTestMocks(); + const eachObject = each.withGlobal(globalTestMocks)([ + {name: 'foo'}, + {name: 'bar'}, + ]); + const testFunction = get(eachObject, keyPath); + testFunction('expected string: $#', () => {}); + + const globalMock = get(globalTestMocks, keyPath); + expect(globalMock).toHaveBeenCalledTimes(2); + expect(globalMock).toHaveBeenCalledWith( + 'expected string: foo 0', + expectFunction, + undefined, + ); + expect(globalMock).toHaveBeenCalledWith( + 'expected string: bar 1', + expectFunction, + undefined, + ); + }); }); }); diff --git a/packages/jest-each/src/table/array.ts b/packages/jest-each/src/table/array.ts index a4fb9d5d0c63..14bc5df89e07 100644 --- a/packages/jest-each/src/table/array.ts +++ b/packages/jest-each/src/table/array.ts @@ -13,7 +13,7 @@ import type {EachTests} from '../bind'; import type {Templates} from './interpolation'; import {interpolateVariables} from './interpolation'; -const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp]/g; +const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp#]/g; const PRETTY_PLACEHOLDER = '%p'; const INDEX_PLACEHOLDER = '%#'; const PLACEHOLDER_PREFIX = '%';