(testOptions)
| 174 | return getters; |
| 175 | |
| 176 | function testResult(testOptions) { |
| 177 | test(options.title || "", async () => { |
| 178 | const result = await promise; |
| 179 | |
| 180 | let snapshot; |
| 181 | for (const name of ["status", "stdout", "stderr", "write"]) { |
| 182 | let value = result[name]; |
| 183 | // \r is trimmed from jest snapshots by default; |
| 184 | // manually replacing this character with /*CR*/ to test its true presence |
| 185 | // If ignoreLineEndings is specified, \r is simply deleted instead |
| 186 | if (name === "stdout" || name === "stderr") { |
| 187 | value = result[name].replace( |
| 188 | /\r/g, |
| 189 | options.ignoreLineEndings ? "" : "/*CR*/", |
| 190 | ); |
| 191 | } |
| 192 | |
| 193 | if (name in testOptions) { |
| 194 | if (name === "status" && testOptions[name] === "non-zero") { |
| 195 | expect(value).not.toBe(0); |
| 196 | } else if (typeof testOptions[name] === "function") { |
| 197 | testOptions[name](value); |
| 198 | } else { |
| 199 | expect(value).toStrictEqual(testOptions[name]); |
| 200 | } |
| 201 | } else { |
| 202 | snapshot = snapshot ?? {}; |
| 203 | snapshot[name] = value; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | if (snapshot) { |
| 208 | expect(snapshot).toMatchSnapshot(); |
| 209 | } |
| 210 | }); |
| 211 | |
| 212 | return getters; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | export default runCli; |
nothing calls this directly
no test coverage detected
searching dependent graphs…