@testomatio/reporter 0.7.5-beta.1 → 0.7.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +4 -0
- package/lib/adapter/mocha.js +2 -2
- package/lib/fileUploader.js +40 -36
- package/package.json +3 -2
package/Changelog.md
CHANGED
package/lib/adapter/mocha.js
CHANGED
|
@@ -8,9 +8,9 @@ const { EVENT_RUN_BEGIN, EVENT_RUN_END, EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_
|
|
|
8
8
|
|
|
9
9
|
function MochaReporter(runner, opts) {
|
|
10
10
|
Mocha.reporters.Base.call(this, runner);
|
|
11
|
-
let passes = 0
|
|
11
|
+
let passes = 0; let failures = 0; let skipped = 0; // eslint-disable-line no-unused-vars
|
|
12
12
|
|
|
13
|
-
const apiKey = opts?.reporterOptions?.apiKey || process.env
|
|
13
|
+
const apiKey = opts?.reporterOptions?.apiKey || process.env.TESTOMATIO;
|
|
14
14
|
|
|
15
15
|
if (!apiKey) {
|
|
16
16
|
console.log('TESTOMATIO key is empty, ignoring reports');
|
package/lib/fileUploader.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { S3 } = require('@aws-sdk/client-s3');
|
|
2
|
+
const { Upload } = require("@aws-sdk/lib-storage");
|
|
2
3
|
const fs = require('fs');
|
|
3
4
|
const path = require('path');
|
|
4
5
|
const chalk = require('chalk');
|
|
@@ -32,6 +33,23 @@ const _getFileExtBase64 = str => {
|
|
|
32
33
|
);
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
const _getS3Config = () => {
|
|
37
|
+
const cfg = {
|
|
38
|
+
region: S3_REGION,
|
|
39
|
+
credentials: {
|
|
40
|
+
accessKeyId: S3_ACCESS_KEY_ID,
|
|
41
|
+
secretAccessKey: S3_SECRET_ACCESS_KEY,
|
|
42
|
+
s3ForcePathStyle: S3_FORCE_PATH_STYLE,
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (S3_ENDPOINT) {
|
|
47
|
+
cfg.endpoint = S3_ENDPOINT;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return cfg;
|
|
51
|
+
}
|
|
52
|
+
|
|
35
53
|
const uploadUsingS3 = async (filePath, runId) => {
|
|
36
54
|
let ContentType;
|
|
37
55
|
let Key;
|
|
@@ -42,18 +60,6 @@ const uploadUsingS3 = async (filePath, runId) => {
|
|
|
42
60
|
Key = filePath.name;
|
|
43
61
|
}
|
|
44
62
|
|
|
45
|
-
const config = {
|
|
46
|
-
region: S3_REGION,
|
|
47
|
-
accessKeyId: S3_ACCESS_KEY_ID,
|
|
48
|
-
secretAccessKey: S3_SECRET_ACCESS_KEY,
|
|
49
|
-
s3ForcePathStyle: S3_FORCE_PATH_STYLE,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
if (S3_ENDPOINT) {
|
|
53
|
-
config.endpoint = new AWS.Endpoint(S3_ENDPOINT);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const s3 = new AWS.S3(config);
|
|
57
63
|
if (!fs.existsSync(filePath)) {
|
|
58
64
|
console.error(chalk.yellow(`Artifacts file ${filePath} does not exist. Skipping...`));
|
|
59
65
|
return;
|
|
@@ -64,18 +70,24 @@ const uploadUsingS3 = async (filePath, runId) => {
|
|
|
64
70
|
Key = `${runId}/${randomUUID()}-${Key || path.basename(filePath)}`;
|
|
65
71
|
const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
|
|
66
72
|
|
|
73
|
+
const s3 = new S3(_getS3Config());
|
|
74
|
+
|
|
67
75
|
try {
|
|
68
|
-
const out =
|
|
69
|
-
|
|
76
|
+
const out = new Upload({
|
|
77
|
+
client: s3,
|
|
78
|
+
|
|
79
|
+
params: {
|
|
70
80
|
Bucket: S3_BUCKET,
|
|
71
81
|
Key,
|
|
72
82
|
Body: file,
|
|
73
83
|
ContentType,
|
|
74
84
|
ACL,
|
|
75
|
-
}
|
|
76
|
-
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await out.done();
|
|
77
89
|
|
|
78
|
-
return out.Location;
|
|
90
|
+
return out.singleUploadResult.Location;
|
|
79
91
|
} catch (e) {
|
|
80
92
|
console.log(APP_PREFIX, chalk.bold.red(`Failed uploading '${Key}'. Please check S3 credentials`), {
|
|
81
93
|
accessKeyId: S3_ACCESS_KEY_ID,
|
|
@@ -100,35 +112,27 @@ const uploadUsingS3 = async (filePath, runId) => {
|
|
|
100
112
|
};
|
|
101
113
|
|
|
102
114
|
const uploadUsingS3AsBuffer = async (buffer, fileName, runId) => {
|
|
103
|
-
const config = {
|
|
104
|
-
region: S3_REGION,
|
|
105
|
-
accessKeyId: S3_ACCESS_KEY_ID,
|
|
106
|
-
secretAccessKey: S3_SECRET_ACCESS_KEY,
|
|
107
|
-
s3ForcePathStyle: S3_FORCE_PATH_STYLE,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
if (S3_ENDPOINT) {
|
|
111
|
-
config.endpoint = new AWS.Endpoint(S3_ENDPOINT);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const s3 = new AWS.S3(config);
|
|
115
|
-
|
|
116
115
|
const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
|
|
117
116
|
|
|
118
117
|
const fileExtension = _getFileExtBase64(buffer.toString('base64'));
|
|
119
118
|
const Key = `${runId}/${fileName}${fileExtension}`;
|
|
120
119
|
|
|
120
|
+
const s3 = new S3(_getS3Config());
|
|
121
|
+
|
|
121
122
|
try {
|
|
122
|
-
const out =
|
|
123
|
-
|
|
123
|
+
const out = new Upload({
|
|
124
|
+
client: s3,
|
|
125
|
+
|
|
126
|
+
params: {
|
|
124
127
|
Bucket: S3_BUCKET,
|
|
125
128
|
Key,
|
|
126
129
|
Body: buffer,
|
|
127
130
|
ACL,
|
|
128
|
-
}
|
|
129
|
-
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
await out.done();
|
|
130
134
|
|
|
131
|
-
return out.Location;
|
|
135
|
+
return out.singleUploadResult.Location;
|
|
132
136
|
} catch (e) {
|
|
133
137
|
console.log(APP_PREFIX, chalk.bold.red(`Failed uploading '${Key}'. Please check S3 credentials`), {
|
|
134
138
|
accessKeyId: S3_ACCESS_KEY_ID,
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6-beta.1",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"main": "./lib/reporter.js",
|
|
6
6
|
"repository": "git@github.com:testomatio/reporter.git",
|
|
7
7
|
"author": "Michael Bodnarchuk <davert@testomat.io>,Koushik Mohan <koushikmohan1996@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"aws-sdk": "^
|
|
10
|
+
"@aws-sdk/client-s3": "^3.279.0",
|
|
11
|
+
"@aws-sdk/lib-storage": "^3.279.0",
|
|
11
12
|
"axios": "^0.25.0",
|
|
12
13
|
"callsite-record": "^4.1.4",
|
|
13
14
|
"chalk": "^4.1.0",
|