-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for test artifacts (videos and screenshots) #171
Comments
Not just for failure. We should support artifacts in general. |
@rotemmiz sometimes screenshots enough. In most cases, video don't need |
Artifacts could include the app’s log, screenshots, video of the test run, profiling data, etc. After the test suit finishes, we need to find a way to take this data from the device and transfer it for export. On simulator, this is easy, but it may be challenging on real devices. Xcode is able to take an app’s container data and export it in an archive. Perhaps we could use this somehow. |
What about just for now use |
Hi Is there an update on this/ETA or a workaround - My tests fails for proxy errors on the server and I would like to take screenshots while its running on the CI to rule out proxy issues. |
Please support this ticket guys, we expect detox will be the first pioneer all-in-one toolkit for QA/automation things dedicated in RN world. |
@fabriziogiordano I'm interested in your suggestion regarding running |
FYI if anyone was lost like I was I was able to get this working on iOS creating the following helper: const { exec } = require('child-process-async');
module.exports = async (elementToBeVisible, fileName) => {
await waitFor(element(by.id(elementToBeVisible)))
.toBeVisible()
.withTimeout(5000);
await exec(
`xcrun simctl io booted screenshot e2e/screenshots/${fileName}.png`
);
}; |
Thoughts on our current state, and how I see this feature: I wasn’t able to merge the current implementation since I felt like it’s not scalable enough. Meaning, my initial approach, the one I asked @donataswix to implement (mentioned at the top of this issue), has a serious flaw. It is very hard to add a new artifacts to the system. Android logs, for instance, were not implemented in this branch, and it seems like it’s going to be very hard to add this capability, let alone adding more artifacts in the future, will cause a code overflow in deviceDrivers. class AndroidVideoArtifactHandler {
...
async start() {
//spawn video process creation here
}
async stop() {
//stop the spawned process
}
async move() {
//as currently implemented in AndroidArtifact
}
async copy() {
//as currently implemented in AndroidArtifact
}
} something like that, not sure its a good enough approach, we need to test it. I’d like your inputs on that @donatas. |
More considerations in the future:
Before implementing artifacts, I think we need to first implement the file transfer infra for each platform. |
Agree with @rotemmiz, current implementation in https://github.com/wix/detox/tree/screenshots-and-videos should be improved. Drivers got polluted with data that could be easily contained in artifact handlers, e.g. AndroidVideoArtifact could hold current process object and handle it's creation and termination. Also, currently Device object is orchestrating recording of screenshots and videos, but these could be delegated to ArtifactsManager which should subsume and replace ArtifactsCopier. New options ( What Device should do in the end is to tell ArtifactsManager what to record and what not to ( |
Hello to all interested, I indeed started my work on the feature, and the current challenge is to refactor it properly. As it was stated previously, we want to avoid tight coupling of Detox internals with the test artifacts feature, since most of it is about spawning and controlling a handful of CLI processes at the right times. Also, we might benefit from making methods Last but not least, in the interim I've noticed that in the artifacts branch This omission concerns me in a sense that Detox, being agnostic to test frameworks and runners, at the moment has no explicit contract for an arbitrary test runner. It is true that we did not need that in the past. Unfortunately, the new artifacts feature needs more points of interaction, for instance:
Altogether, it brought me to the following stance:
It's a bit hard to track my progress since it is quite chaotic movement here-and-there, which is uniformly and messily distributed between three branches: feature/detox-artifacts-plugin, refactor/test-runners, and the original one, plus some local files and quite a recent Jest PoC. I'll do my best to make my scope of work more focused in the nearest days and will be gladly updating you and listening to your input. Cheers! |
Quick update, guys. We've found a sweet spot between what is best and what is just good enough. The work is going on in this (last and final) artifacts branch: https://github.com/wix/detox/compare/feature/test-artifacts . To great relief, there's no need to scatter work across branches - I have a focus now (at last :). Within next couple of days, I'll create a new WIP Pull Request instead of #541 , so that my progress will be more visible and transparent to us all. I'll make sure to create a checklist in the PR description and keep it in sync with my progress. I have a cautious hope to finish work on artifacts quite soon. Still, besides the parts I clearly understand how to accomplish, there are less predictable ones: infrastructure work to improve iOS log recording code, merging low-level parts of iOS screenshotting and screen recording from the former pull request. Maybe we'll postpone implementing Android log recording. Anyway, a few big challenges on structuring have been solved, as well as integration with both Mocha and Jest (as a bonus, Many thanks for your patience! |
@rotemmiz , can we close this? |
We want to add the following to an artifact directory for each failed test:
Video of the test from start to finish (using- New details belowfbsimctl record
)Device log (can be extracted from- Implemented~/Library/Logs/CoreSimulator/{udid}/system.log
EDIT:
Detailed requirements and implementation guide:
iOS
xcrun simctl io udid recordVideo <filename>.<mp4|mov>
, this functionality needs to be added to the wrapper classAppleSimUtils
. This should be implemented usingsapwn
, and notexec
since this process is not detaching, it actually listens tosigterm
to finish its job, so it can be implemented in a similar way asspawnEmulator
Similarly, add screenshot functionality using
xcrun simctl io booted screenshot
, add it to the same place.Add
takeScreenshot
andrecordVideo
empty functions inDeviceDriverBase
Implement both functions in
SimulatorDriver
'stakeScreenshot
andrecordVideo
functions.Android
ADB
spawn
- add toADB
AndroidDriver
'stakeScreenshot
andrecordVideo
functions - this will also add support for screenshot and video taking on Android Devices.adb logcat
, in the same scope as we do on iOS, for feature parity.API
The newly generated files need to be arranged in folders arranged by test names. There is already an internal tool for that called
ArtifactsCopier
. The current implementation is a bit lacking since every artifact type needs to be added manually.In the scope of this task I would also like to fix this, adding an internal API to register new artifact types (suggestions are welcome)...
When work is done and artifacts are registered into ArtifactsCopier, each test should generate 3 artifacts:
The text was updated successfully, but these errors were encountered: