mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-28 18:08:11 +08:00
934cc5c69b
* Added TS. Updated build and linting config. Added types. * [ts-migrate][.] Rename files from JS/JSX to TS/TSX Co-authored-by: ts-migrate <> * [ts-migrate][.] Run TS Migrate Co-authored-by: ts-migrate <> * Corrected files mangled by ts-migrate. * Updated lint config, minor linting. * Re-enabled Husky. * Updated tests and config. * Reverted webpack devtool config. * Removed obsolete snapshots. * Added annotations snap. * Updated tsconfig includes wrt linting. * Removed ts-migrate. Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
const PuppeteerEnvironment = require("jest-environment-puppeteer");
|
|
require("jest-circus");
|
|
const ENV_DEFAULT = require("../../../environment.default.json");
|
|
|
|
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'takeScreen... Remove this comment to see the full error message
|
|
const takeScreenshot = require("./takeScreenshot");
|
|
|
|
class ScreenshotEnvironment extends PuppeteerEnvironment {
|
|
async handleTestEvent(event, state) {
|
|
if (["test_start", "test_done"].includes(event.name)) {
|
|
console.log("------------------event name:\n", event.name);
|
|
console.log("~~~~ Current test errors\n", new Date(), event.test.errors);
|
|
console.log("~~~~ Current test\n", new Date(), event.test);
|
|
}
|
|
|
|
if (event.name === "error") {
|
|
console.log("error event:", JSON.stringify(event));
|
|
}
|
|
|
|
if (event.name === "test_fn_failure" || event.name === "hook_failure") {
|
|
console.log("------------------event name:\n", event.name);
|
|
console.log(">>>> Current state\n", new Date(), state);
|
|
console.log("===> Failure event\n", new Date(), event);
|
|
|
|
// (thuang): We only want to take screenshot on the last try
|
|
if (
|
|
state.currentlyRunningTest.invocations <= ENV_DEFAULT.RETRY_ATTEMPTS
|
|
) {
|
|
return;
|
|
}
|
|
|
|
await takeScreenshot(state.currentlyRunningTest.name, this.global.page);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = ScreenshotEnvironment;
|