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

Function json

e2e/runJest.ts:162–182  ·  view source on GitHub ↗
(
  dir: string,
  args?: Array<string>,
  options: RunJestOptions = {},
)

Source from the content-addressed store, hash-verified

160// 'numRuntimeErrorTestSuites', 'numPassedTests', 'numFailedTests',
161// 'numPendingTests', 'testResults'
162export const json = function (
163 dir: string,
164 args?: Array<string>,
165 options: RunJestOptions = {},
166): RunJestJsonResult {
167 args = [...(args || []), '--json'];
168 const result = runJest(dir, args, options);
169 try {
170 return {
171 ...result,
172 json: JSON.parse(result.stdout),
173 };
174 } catch (error: any) {
175 throw new Error(dedent`
176 Can't parse JSON.
177 ERROR: ${error.name} ${error.message}
178 STDOUT: ${result.stdout}
179 STDERR: ${result.stderr}
180 `);
181 }
182};
183
184type StdErrAndOutString = {stderr: string; stdout: string};
185type ConditionFunction = (arg: StdErrAndOutString) => boolean;

Calls 1

runJestFunction · 0.70

Tested by

no test coverage detected