(
dir: string,
args?: Array<string>,
options: RunJestOptions = {},
)
| 160 | // 'numRuntimeErrorTestSuites', 'numPassedTests', 'numFailedTests', |
| 161 | // 'numPendingTests', 'testResults' |
| 162 | export 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 | |
| 184 | type StdErrAndOutString = {stderr: string; stdout: string}; |
| 185 | type ConditionFunction = (arg: StdErrAndOutString) => boolean; |
no test coverage detected