Summary: - Also move out reused helper methods out of test suites, to avoid inadvertently including some test suites into other suites. - Add logging around onNewTab since that seems related to test failures. - Skip several tests in Billing that fail particularly often. Test Plan: Checking that tests pass, and how many. Compared to the last successful run on master, there are 4 new skips (this diff), and 3 fewer test cases (a test case run in triplicate was removed in https://github.com/gristlabs/grist-core/pull/899) Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D4216pull/911/head
parent
ff8477cbe4
commit
aff9c7075c
@ -0,0 +1,44 @@
|
||||
import log from 'app/server/lib/log';
|
||||
import {assert, driver} from 'mocha-webdriver';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs/promises';
|
||||
|
||||
|
||||
export async function fetchScreenshotAndLogs(test: Mocha.Runnable|undefined) {
|
||||
const dir = process.env.MOCHA_WEBDRIVER_LOGDIR!;
|
||||
assert.isOk(dir, "driverLogging: MOCHA_WEBDRIVER_LOGDIR not set");
|
||||
const testName = test?.file ? path.basename(test.file, path.extname(test.file)) : "unnamed";
|
||||
const logPath = path.resolve(dir, `${testName}-driverLogging.log`);
|
||||
await fs.mkdir(dir, {recursive: true});
|
||||
await driver.saveScreenshot(`${testName}-driverLoggingScreenshot-{N}.png`);
|
||||
const messages = await driver.fetchLogs('driver');
|
||||
await fs.appendFile(logPath, messages.join("\n") + "\n");
|
||||
}
|
||||
|
||||
export async function withDriverLogging(
|
||||
test: Mocha.Runnable|undefined, periodMs: number, timeoutMs: number,
|
||||
callback: () => Promise<void>
|
||||
) {
|
||||
let running = false;
|
||||
async function repeat() {
|
||||
if (running) {
|
||||
log.warn("driverLogging: skipping because previous repeat still running");
|
||||
return;
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await fetchScreenshotAndLogs(test);
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
const periodic = setInterval(repeat, periodMs);
|
||||
const timeout = setTimeout(() => clearInterval(periodic), timeoutMs);
|
||||
try {
|
||||
return await callback();
|
||||
} finally {
|
||||
clearInterval(periodic);
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue