Check if test failed in afterEach of Jest
问题 When one of my Jest tests fails I want to store a screenshot, but only when it fails. Here is a piece of my test code as an example, the !passed part in the afterEach is not working. describe('Page', () => { it('should contain Text in the header', async () => { // Arrange const page = new Page(driver); // Act await page.open(); // Assert expect(await page.getHeaderText()).toBe('Something'); }); afterEach(async () => { if (!passed) takeScreenshot(); await driver.quit(); }); }); With jasmine I