Describe the bug
I am using jest-puppeteer's PuppeteerEnvrironment together with allure-jest reporter. Everything seems to work well, except of #handleTestEvent function from custom env:
To Reproduce
custom-environment.ts:
import { createJestEnvironment } from "allure-jest/factory";
import PuppeteerEnvironment from "jest-environment-puppeteer";
class CustomEnvironment extends PuppeteerEnvironment {
async handleTestEvent(event) {
console.error(
`handleTestEvent: ${event.name}, errors: ${event.test?.errors?.length}`,
);
if (event.name === "test_fn_failure") {
this.global.page.screenshot(...);
}
}
}
}
module.exports = createJestEnvironment(CustomEnvironment);
Expected behavior
function is invoked
Additional context
This is needed to ensure screenshots on failure are created consistently, i.e. when expect.getState() assertions pass, but test throws unrelated error in runtime (i.e. originating from internal component):
const hasCurrentTestFailed = () => {
const { assertionCalls, numPassingAsserts } = expect.getState();
return assertionCalls === 0 || assertionCalls > numPassingAsserts;
};
afterEach(async () => {
try {
if (hasCurrentTestFailed()) {
// unreachable code ...
page.screenshot()
Describe the bug
I am using jest-puppeteer's PuppeteerEnvrironment together with allure-jest reporter. Everything seems to work well, except of #handleTestEvent function from custom env:
To Reproduce
custom-environment.ts:
Expected behavior
function is invoked
Additional context
This is needed to ensure screenshots on failure are created consistently, i.e. when
expect.getState()assertions pass, but test throws unrelated error in runtime (i.e. originating from internal component):