MCPcopy
hub / github.com/jestjs/jest / interpolateVariables

Function interpolateVariables

packages/jest-each/src/table/interpolation.ts:16–33  ·  view source on GitHub ↗
(
  title: string,
  template: Template,
  index: number,
)

Source from the content-addressed store, hash-verified

14export type Headings = Array<string>;
15
16export const interpolateVariables = (
17 title: string,
18 template: Template,
19 index: number,
20): string =>
21 title
22 .replaceAll(
23 new RegExp(`\\$(${Object.keys(template).join('|')})[.\\w]*`, 'g'),
24 match => {
25 const keyPath = match.slice(1).split('.');
26 const value = getPath(template, keyPath);
27
28 return isPrimitive(value)
29 ? String(value)
30 : pretty(value, {maxDepth: 1, min: true});
31 },
32 )
33 .replace('$#', `${index}`);
34
35/* eslint import-x/export: 0*/
36export function getPath<

Callers 2

arrayFunction · 0.90
templateFunction · 0.90

Calls 2

isPrimitiveFunction · 0.90
getPathFunction · 0.70

Tested by

no test coverage detected