qase-javascript-commons 2.0.0-beta.4 → 2.0.0-beta.5
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 +7 -0
- package/dist/config/config-validation-schema.js +4 -0
- package/dist/env/env-enum.d.ts +2 -1
- package/dist/env/env-enum.js +1 -0
- package/dist/env/env-to-config.js +1 -0
- package/dist/env/env-type.d.ts +1 -0
- package/dist/env/env-validation-schema.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/options/options-type.d.ts +1 -0
- package/dist/qase.js +7 -3
- package/dist/reporters/abstract-reporter.d.ts +15 -0
- package/dist/reporters/abstract-reporter.js +12 -1
- package/dist/utils/mimeTypes.d.ts +5 -0
- package/dist/utils/mimeTypes.js +41 -0
- package/package.json +6 -3
package/changelog.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# qase-javascript-commons@2.0.0-beta.5
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
* Update the config of reporters. Added `framework.captureLogs` field. If it is set to `true`, the reporter will capture logs from the test framework.
|
|
6
|
+
* Added `getMimeType` function to the commons package. It returns the MIME type of the file by its extension.
|
|
7
|
+
|
|
1
8
|
# qase-javascript-commons@2.0.0-beta.4
|
|
2
9
|
|
|
3
10
|
## What's new
|
package/dist/env/env-enum.d.ts
CHANGED
package/dist/env/env-enum.js
CHANGED
|
@@ -10,6 +10,7 @@ var EnvEnum;
|
|
|
10
10
|
EnvEnum["fallback"] = "QASE_FALLBACK";
|
|
11
11
|
EnvEnum["debug"] = "QASE_DEBUG";
|
|
12
12
|
EnvEnum["environment"] = "QASE_ENVIRONMENT";
|
|
13
|
+
EnvEnum["captureLogs"] = "QASE_CAPTURE_LOGS";
|
|
13
14
|
})(EnvEnum || (exports.EnvEnum = EnvEnum = {}));
|
|
14
15
|
/**
|
|
15
16
|
* @enum {string}
|
|
@@ -11,6 +11,7 @@ const envToConfig = (env) => ({
|
|
|
11
11
|
mode: env[env_enum_1.EnvEnum.mode],
|
|
12
12
|
debug: env[env_enum_1.EnvEnum.debug],
|
|
13
13
|
environment: env[env_enum_1.EnvEnum.environment],
|
|
14
|
+
captureLogs: env[env_enum_1.EnvEnum.captureLogs],
|
|
14
15
|
testops: {
|
|
15
16
|
project: env[env_enum_1.EnvTestOpsEnum.project],
|
|
16
17
|
uploadAttachments: env[env_enum_1.EnvTestOpsEnum.uploadAttachments],
|
package/dist/env/env-type.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type EnvType = {
|
|
|
6
6
|
[EnvEnum.fallback]?: `${ModeEnum}`;
|
|
7
7
|
[EnvEnum.debug]?: boolean;
|
|
8
8
|
[EnvEnum.environment]?: string | number;
|
|
9
|
+
[EnvEnum.captureLogs]?: boolean;
|
|
9
10
|
[EnvTestOpsEnum.project]?: string;
|
|
10
11
|
[EnvTestOpsEnum.uploadAttachments]?: boolean;
|
|
11
12
|
[EnvTestOpsEnum.chunk]?: number;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export type OptionsType = {
|
|
|
21
21
|
reporterName: string;
|
|
22
22
|
mode?: `${ModeEnum}` | undefined;
|
|
23
23
|
fallback?: `${ModeEnum}` | undefined;
|
|
24
|
+
captureLogs?: boolean | undefined;
|
|
24
25
|
debug?: boolean | undefined;
|
|
25
26
|
environment?: string | number | undefined;
|
|
26
27
|
testops?: (RecursivePartial<TestOpsOptionsType> & AdditionalTestOpsOptionsType) | undefined;
|
package/dist/qase.js
CHANGED
|
@@ -71,7 +71,7 @@ class QaseReporter extends reporters_1.AbstractReporter {
|
|
|
71
71
|
constructor(options, logger) {
|
|
72
72
|
const env = (0, env_1.envToConfig)((0, env_schema_1.default)({ schema: env_1.envValidationSchema }));
|
|
73
73
|
const composedOptions = (0, options_1.composeOptions)(options, env);
|
|
74
|
-
super({ debug: composedOptions.debug }, logger);
|
|
74
|
+
super({ debug: composedOptions.debug, captureLogs: composedOptions.captureLogs }, logger);
|
|
75
75
|
/**
|
|
76
76
|
* @type {boolean}
|
|
77
77
|
* @private
|
|
@@ -233,13 +233,17 @@ class QaseReporter extends reporters_1.AbstractReporter {
|
|
|
233
233
|
},
|
|
234
234
|
plan,
|
|
235
235
|
chunk,
|
|
236
|
-
|
|
236
|
+
debug: commonOptions.debug,
|
|
237
|
+
captureLogs: commonOptions.captureLogs,
|
|
237
238
|
}, apiClient, logger, typeof environment === 'number' ? environment : undefined);
|
|
238
239
|
}
|
|
239
240
|
case options_1.ModeEnum.report: {
|
|
240
241
|
const localOptions = report.connections?.[writer_1.DriverEnum.local];
|
|
241
242
|
const writer = new writer_1.FsWriter(localOptions);
|
|
242
|
-
return new reporters_1.ReportReporter(
|
|
243
|
+
return new reporters_1.ReportReporter({
|
|
244
|
+
debug: commonOptions.debug,
|
|
245
|
+
captureLogs: commonOptions.captureLogs,
|
|
246
|
+
}, writer, logger, typeof environment === 'number' ? environment.toString() : environment, testops.run?.id);
|
|
243
247
|
}
|
|
244
248
|
case options_1.ModeEnum.off:
|
|
245
249
|
throw new disabled_exception_1.DisabledException();
|
|
@@ -6,12 +6,14 @@ export interface LoggerInterface {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ReporterOptionsType {
|
|
8
8
|
debug?: boolean | undefined;
|
|
9
|
+
captureLogs?: boolean | undefined;
|
|
9
10
|
}
|
|
10
11
|
export interface ReporterInterface {
|
|
11
12
|
addTestResult(result: TestResultType): void;
|
|
12
13
|
publish(): Promise<void>;
|
|
13
14
|
getTestResults(): TestResultType[];
|
|
14
15
|
setTestResults(results: TestResultType[]): void;
|
|
16
|
+
isCaptureLogs(): boolean;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* @abstract
|
|
@@ -25,6 +27,15 @@ export declare abstract class AbstractReporter implements ReporterInterface {
|
|
|
25
27
|
* @private
|
|
26
28
|
*/
|
|
27
29
|
private readonly debug;
|
|
30
|
+
/**
|
|
31
|
+
* @type {boolean | undefined}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private readonly captureLogs;
|
|
35
|
+
/**
|
|
36
|
+
* @type {TestResultType[]}
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
28
39
|
protected results: TestResultType[];
|
|
29
40
|
/**
|
|
30
41
|
* @returns {Promise<void>}
|
|
@@ -40,6 +51,10 @@ export declare abstract class AbstractReporter implements ReporterInterface {
|
|
|
40
51
|
* @returns {TestResultType[]}
|
|
41
52
|
*/
|
|
42
53
|
getTestResults(): TestResultType[];
|
|
54
|
+
/**
|
|
55
|
+
* @returns {boolean}
|
|
56
|
+
*/
|
|
57
|
+
isCaptureLogs(): boolean;
|
|
43
58
|
/**
|
|
44
59
|
* @param {TestResultType} result
|
|
45
60
|
*/
|
|
@@ -21,9 +21,14 @@ class AbstractReporter {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(options, logger = console) {
|
|
23
23
|
this.logger = logger;
|
|
24
|
+
/**
|
|
25
|
+
* @type {TestResultType[]}
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
24
28
|
this.results = [];
|
|
25
|
-
const { debug } = options ?? {};
|
|
29
|
+
const { debug, captureLogs } = options ?? {};
|
|
26
30
|
this.debug = debug;
|
|
31
|
+
this.captureLogs = captureLogs;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* @returns {TestResultType[]}
|
|
@@ -31,6 +36,12 @@ class AbstractReporter {
|
|
|
31
36
|
getTestResults() {
|
|
32
37
|
return this.results;
|
|
33
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/
|
|
42
|
+
isCaptureLogs() {
|
|
43
|
+
return this.captureLogs ?? false;
|
|
44
|
+
}
|
|
34
45
|
/**
|
|
35
46
|
* @param {TestResultType} result
|
|
36
47
|
*/
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getMimeTypes = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const mime = __importStar(require("mime-types"));
|
|
29
|
+
/**
|
|
30
|
+
* Get mime type of the file
|
|
31
|
+
* @param {string} filePath
|
|
32
|
+
*/
|
|
33
|
+
function getMimeTypes(filePath) {
|
|
34
|
+
const fileName = path.basename(filePath);
|
|
35
|
+
const mimeType = mime.contentType(fileName);
|
|
36
|
+
if (!mimeType && typeof mimeType !== 'string') {
|
|
37
|
+
return 'application/octet-stream';
|
|
38
|
+
}
|
|
39
|
+
return mimeType;
|
|
40
|
+
}
|
|
41
|
+
exports.getMimeTypes = getMimeTypes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qase-javascript-commons",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "Qase JS Reporters",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ajv": "^8.12.0",
|
|
28
28
|
"chalk": "^4.1.2",
|
|
29
|
+
"child-process-ext": "^3.0.2",
|
|
29
30
|
"env-schema": "^5.2.0",
|
|
30
31
|
"form-data": "^4.0.0",
|
|
31
32
|
"lodash.get": "^4.4.2",
|
|
32
33
|
"lodash.merge": "^4.6.2",
|
|
33
34
|
"lodash.mergewith": "^4.6.2",
|
|
35
|
+
"mime-types": "^2.1.33",
|
|
34
36
|
"qaseio": "^2.1.0-beta.1",
|
|
35
37
|
"strip-ansi": "^6.0.1",
|
|
36
|
-
"uuid": "^9.0.0"
|
|
37
|
-
"child-process-ext": "^3.0.2"
|
|
38
|
+
"uuid": "^9.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@jest/globals": "^29.5.0",
|
|
@@ -42,6 +43,8 @@
|
|
|
42
43
|
"@types/lodash.get": "^4.4.7",
|
|
43
44
|
"@types/lodash.merge": "^4.6.7",
|
|
44
45
|
"@types/lodash.mergewith": "^4.6.7",
|
|
46
|
+
"@types/mime-types": "^2.1.4",
|
|
47
|
+
"@types/node": "^20.12.5",
|
|
45
48
|
"@types/uuid": "^9.0.1",
|
|
46
49
|
"axios": "^0.21.4",
|
|
47
50
|
"jest": "^29.5.0",
|