Detox: Take screenshot after test failure, before afterEach is executed

Created on 18 Sep 2019  路  7Comments  路  Source: wix/Detox

It is common to put additional logic in afterEach step (to return to primary state, make additional repetitive checks, etc).
With current implementation, when the test fails, afterEach is being executed and only THEN screenshot is taken. It means that other screen could be opened already, so screen where bug happened is not visible anymore. This way it is harder to analyze bug failures, as you do not have corresponding screenshot.

Please implement taking screenshot at the start of afterEach statement.

acceptebug 馃搶 pinned

Most helpful comment

Whatever, the issue is accepted.

All 7 comments

This is probably a bug, rather than enhancement. Failing screenshots need to be taken as early as possible.

It will not do the trick. _flushScreenshots transfers already made screenshots to the target location.

And it is not a bug.
afterEach in its current understanding should be left as-is because it still represents a valid case for video recordings. Video recording should be finished later, not sooner, even if it is a failing test. Moreover, if an error happens inside afterEach, we also cover this case.

The requested functionality needs extra enhancement to the test runner adapters and detox artifacts lifecycle. Either we should strive to add a lifecycle event onError, or a sort of afterEachImmediate. Then we could map the screenshotter to that more satisfying event.

Bug in design is still a bug. The screenshots are useless in this case. Screenshots should be taken as close to failure point as possible.

Whatever, the issue is accepted.

The support for error.png screenshots will come to Detox + jest-circus.

The feature will appear in [email protected].

Was this page helpful?
0 / 5 - 0 ratings