parent
a1fb7b6999
commit
f9877b1978
|
@ -180,7 +180,7 @@ function loadTestModules(opts) {
|
|||
/** @type Mocha.Test */
|
||||
let currentTest;
|
||||
|
||||
function loadTests(opts) {
|
||||
async function loadTests(opts) {
|
||||
|
||||
//#region Unexpected Output
|
||||
|
||||
|
@ -194,6 +194,8 @@ function loadTests(opts) {
|
|||
_allowedTestOutput.push(/Deleting [0-9]+ old snapshots/);
|
||||
}
|
||||
|
||||
const perTestCoverage = opts['per-test-coverage'] ? await PerTestCoverage.init() : undefined;
|
||||
|
||||
const _allowedTestsWithOutput = new Set([
|
||||
'creates a snapshot', // self-testing
|
||||
'validates a snapshot', // self-testing
|
||||
|
@ -283,7 +285,12 @@ function loadTests(opts) {
|
|||
});
|
||||
});
|
||||
|
||||
setup(async () => {
|
||||
await perTestCoverage?.startTest();
|
||||
});
|
||||
|
||||
teardown(async () => {
|
||||
await perTestCoverage?.finishTest(currentTest.file, currentTest.fullTitle());
|
||||
|
||||
// should not have unexpected output
|
||||
if (_testsWithUnexpectedOutput && !opts.dev) {
|
||||
|
@ -445,3 +452,21 @@ ipcRenderer.on('run', async (_e, opts) => {
|
|||
ipcRenderer.send('error', err);
|
||||
}
|
||||
});
|
||||
|
||||
class PerTestCoverage {
|
||||
static async init() {
|
||||
await ipcRenderer.invoke('startCoverage');
|
||||
return new PerTestCoverage();
|
||||
}
|
||||
|
||||
async startTest() {
|
||||
if (!this.didInit) {
|
||||
this.didInit = true;
|
||||
await ipcRenderer.invoke('snapshotCoverage');
|
||||
}
|
||||
}
|
||||
|
||||
async finishTest(file, fullTitle) {
|
||||
await ipcRenderer.invoke('snapshotCoverage', { file, fullTitle });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue