Skip to content

Commit

Permalink
feat: provide an opt to skip s3 upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Jun 4, 2024
1 parent da3858f commit 7466f6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,19 @@ 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": "<location of base folder>",
"diffFolder": "<location of diff folder>",
"aws": {
"accessKeyId" : "<Your AccessKeyId>",
"secretAccessKey": "<Your secretAccessKey>",
"region": "<Region of Bucket>",
"bucketName": "<Bucket Name>"
"bucketName": "<Bucket Name>",
"skipS3Upload": true,
}
}
}
Expand All @@ -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:
Expand Down
22 changes: 13 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit 7466f6e

Please sign in to comment.