From 7466f6ef3a5ad19bc4aa7127adb51fb3d90c3c60 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 4 Jun 2024 11:19:56 +0200 Subject: [PATCH] feat: provide an opt to skip s3 upload --- README.md | 8 +++++--- src/index.ts | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 333cc20..cb42a87 100644 --- a/README.md +++ b/README.md @@ -161,10 +161,10 @@ Set `output` to where the generated report is to be stored. Default is the outpu ### AWS Support AWS S3 support to upload and download various images is also provided. It can be used by adding the *aws* code inside `"ResembleHelper"` in the `"helpers"` section in config file. The final result should look like: -```json +```js { "helpers": { - "ResembleHelper" : { + "ResembleHelper": { "require": "codeceptjs-resemblehelper", "baseFolder": "", "diffFolder": "", @@ -172,7 +172,8 @@ It can be used by adding the *aws* code inside `"ResembleHelper"` in the `"helpe "accessKeyId" : "", "secretAccessKey": "", "region": "", - "bucketName": "" + "bucketName": "", + "skipS3Upload": true, } } } @@ -183,6 +184,7 @@ This base image has to be located inside a folder named "*base*". The resultant output image will be uploaded in a folder named "*output*" and diff image will be uploaded to a folder named "*diff*" in the S3 bucket. If the `prepareBaseImage` option is marked `true`, then the generated base image will be uploaded to a folder named "*base*" in the S3 bucket. > Note: The tests may take a bit longer to run when the AWS configuration is provided as determined by the internet speed to upload/download images. +> Note: if you want to skip the s3 upload, set skipS3Upload to true. ### Other S3 Providers The same configuration as above, but with *endpoint* field: diff --git a/src/index.ts b/src/index.ts index 99120fd..47bb1ca 100644 --- a/src/index.ts +++ b/src/index.ts @@ -441,15 +441,19 @@ class ResembleHelper extends Helper { await this._addAttachment(baseImage, misMatch, options); await this._addMochaContext(baseImage, misMatch, options); if (awsC !== undefined) { - await this._upload( - awsC.accessKeyId, - awsC.secretAccessKey, - awsC.region, - awsC.bucketName, - baseImage, - options, - awsC.endpoint, - ); + if (awsC.skipS3Upload) { + this.debug(`Uploading to S3 is skipped due to skipS3Upload is set`); + } else { + await this._upload( + awsC.accessKeyId, + awsC.secretAccessKey, + awsC.region, + awsC.bucketName, + baseImage, + options, + awsC.endpoint, + ); + } } this.debug(`MisMatch Percentage Calculated is ${misMatch} for baseline ${baseImage}`);