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.
This is probably a bug, rather than enhancement. Failing screenshots need to be taken as early as possible.
I am assuming that flipping these two lines will do the trick.
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].
Most helpful comment
Whatever, the issue is accepted.