Add a new `observeRunsFromConfig` experiment, which allows a test run to be observed by a function installed through an `ava.config.*` file. The function has access to AVA's internal events, which can then be used to report to a file. AVA's internal event structure is not currently covered by any SemVer guarantees, which is why this feature requires the experimental opt-in. Does not currently support watch mode. Only the first run is observed.
12 lines
341 B
JavaScript
12 lines
341 B
JavaScript
export async function * asyncEventIteratorFromApi(api) {
|
|
// TODO: support multiple runs (watch mode)
|
|
const {value: plan} = await api.events('run').next();
|
|
|
|
for await (const stateChange of plan.status.events('stateChange')) {
|
|
yield stateChange;
|
|
|
|
if (stateChange.type === 'end' || stateChange.type === 'interrupt') {
|
|
break;
|
|
}
|
|
}
|
|
}
|