Describe your idea
It would be great if we overwrite artifacts such as screenshots or videos by passing through a flag e.g. --overwrite-artifacts.
I've managed to get this working locally by adding the following patch to node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js -> moveTemporaryFile method:
diff --git a/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js b/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js
index 7f07040..593662d 100644
--- a/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js
+++ b/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js
@@ -87,6 +87,12 @@ class FileArtifact extends Artifact {
return true;
}
+ if (await fs.exists(destination)) {
+ logger.debug({ event: 'MOVE_FILE_OVERWRITE' }, `moving "${source}" to ${destination}`);
+ await fs.move(source, destination, { overwrite: true });
+ return true;
+ }
+
logger.warn({ event: 'MOVE_FILE_EXISTS' }, `cannot overwrite: "${source}" => "${destination}"`);
await fs.remove(source);
return false;
It checks if the file exists at the destination and then passes through the flag option overwrite: true to fs.move
Describe your idea
It would be great if we overwrite artifacts such as screenshots or videos by passing through a flag e.g.
--overwrite-artifacts.I've managed to get this working locally by adding the following patch to
node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js->moveTemporaryFilemethod:It checks if the file exists at the destination and then passes through the flag option
overwrite: truetofs.move