cypress-qase-reporter 3.0.0-beta.1 → 3.0.0-beta.2
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/README.md +17 -2
- package/dist/configSchema.js +6 -0
- package/dist/hooks.d.ts +7 -1
- package/dist/hooks.js +58 -19
- package/dist/options.d.ts +1 -0
- package/dist/reporter.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -76,9 +76,9 @@ run the following steps:
|
|
|
76
76
|
}
|
|
77
77
|
...
|
|
78
78
|
|
|
79
|
-
## Updating from v2.3.x to v3.0.0-beta.
|
|
79
|
+
## Updating from v2.3.x to v3.0.0-beta.2
|
|
80
80
|
|
|
81
|
-
To update an existing test project using Qase reporter from version 2.3.x to version 3.0.0-beta.
|
|
81
|
+
To update an existing test project using Qase reporter from version 2.3.x to version 3.0.0-beta.2,
|
|
82
82
|
run the following steps:
|
|
83
83
|
|
|
84
84
|
1. Update reporter configuration in `cypress.config.js` file.
|
|
@@ -86,6 +86,21 @@ run the following steps:
|
|
|
86
86
|
```diff
|
|
87
87
|
+ import { afterSpecHook } from 'cypress-qase-reporter/hooks';
|
|
88
88
|
...
|
|
89
|
+
reporter: 'cypress-multi-reporters',
|
|
90
|
+
reporterOptions: {
|
|
91
|
+
reporterEnabled: 'cypress-qase-reporter',
|
|
92
|
+
cypressQaseReporterReporterOptions: {
|
|
93
|
+
... // other options
|
|
94
|
+
framework: {
|
|
95
|
+
cypress: {
|
|
96
|
+
screenshotsFolder: 'cypress/screenshots',
|
|
97
|
+
+ videosFolder: 'cypress/videos',
|
|
98
|
+
+ uploadDelay: 10, // Delay in seconds before uploading video files (default: 10)
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
video: true,
|
|
89
104
|
e2e: {
|
|
90
105
|
setupNodeEvents(on, config) {
|
|
91
106
|
require('cypress-qase-reporter/plugin')(on, config)
|
package/dist/configSchema.js
CHANGED
package/dist/hooks.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
import PluginConfigOptions = Cypress.PluginConfigOptions;
|
|
3
|
+
import Spec = Cypress.Spec;
|
|
4
|
+
declare function beforeRunHook(options: PluginConfigOptions): Promise<void>;
|
|
5
|
+
declare function afterRunHook(options: PluginConfigOptions): Promise<void>;
|
|
6
|
+
declare function afterSpecHook(spec: Spec, options: PluginConfigOptions): Promise<void>;
|
|
7
|
+
export { beforeRunHook, afterRunHook, afterSpecHook, };
|
package/dist/hooks.js
CHANGED
|
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.afterSpecHook = exports.afterRunHook = exports.beforeRunHook = void 0;
|
|
7
8
|
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
8
9
|
const configSchema_1 = require("./configSchema");
|
|
9
10
|
const resultsManager_1 = require("./metadata/resultsManager");
|
|
10
11
|
const fileSearcher_1 = require("./fileSearcher");
|
|
11
12
|
const uuid_1 = require("uuid");
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
15
|
async function beforeRunHook(options) {
|
|
14
16
|
const configLoader = new qase_javascript_commons_1.ConfigLoader(configSchema_1.configSchema);
|
|
15
17
|
const config = configLoader.load();
|
|
@@ -26,6 +28,7 @@ async function beforeRunHook(options) {
|
|
|
26
28
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
27
29
|
await reporter.startTestRunAsync();
|
|
28
30
|
}
|
|
31
|
+
exports.beforeRunHook = beforeRunHook;
|
|
29
32
|
async function afterRunHook(options) {
|
|
30
33
|
const configLoader = new qase_javascript_commons_1.ConfigLoader(configSchema_1.configSchema);
|
|
31
34
|
const config = configLoader.load();
|
|
@@ -41,6 +44,7 @@ async function afterRunHook(options) {
|
|
|
41
44
|
});
|
|
42
45
|
await reporter.complete();
|
|
43
46
|
}
|
|
47
|
+
exports.afterRunHook = afterRunHook;
|
|
44
48
|
async function afterSpecHook(spec, options) {
|
|
45
49
|
const results = resultsManager_1.ResultsManager.getResults();
|
|
46
50
|
if (results) {
|
|
@@ -58,24 +62,63 @@ async function afterSpecHook(spec, options) {
|
|
|
58
62
|
});
|
|
59
63
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
60
64
|
const videosFolder = composedOptions.framework?.cypress?.videosFolder;
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
66
|
+
const uploadVideos = composedOptions.testops?.uploadAttachments !== false;
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
68
|
+
const uploadDelay = composedOptions.framework?.cypress?.uploadDelay ?? 10;
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
61
70
|
const specFileName = path_1.default.basename(spec.name, '.cy.js');
|
|
62
71
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
63
72
|
const videoFiles = videosFolder ? fileSearcher_1.FileSearcher.findVideoFiles(videosFolder, specFileName) : [];
|
|
64
|
-
if (videoFiles.length > 0) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
if (videoFiles.length > 0 && uploadVideos) {
|
|
74
|
+
const existingVideoFiles = videoFiles.filter(file => fs_1.default.existsSync(file));
|
|
75
|
+
if (existingVideoFiles.length === 0) {
|
|
76
|
+
console.warn('No video files found for upload');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Add delay before uploading videos
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
81
|
+
console.log(`Waiting ${uploadDelay} seconds before uploading video files...`);
|
|
82
|
+
await new Promise(resolve => setTimeout(resolve, uploadDelay * 1000));
|
|
83
|
+
const videoAttachments = existingVideoFiles.map((file) => {
|
|
84
|
+
const stats = fs_1.default.statSync(file);
|
|
85
|
+
const attachment = {
|
|
86
|
+
content: '',
|
|
87
|
+
id: (0, uuid_1.v4)(),
|
|
88
|
+
mime_type: 'video/mp4',
|
|
89
|
+
size: stats.size,
|
|
90
|
+
file_name: path_1.default.basename(file),
|
|
91
|
+
file_path: file,
|
|
92
|
+
};
|
|
93
|
+
return attachment;
|
|
78
94
|
});
|
|
95
|
+
try {
|
|
96
|
+
console.log(`Attempting to upload ${videoAttachments.length} video files...`);
|
|
97
|
+
const videoHashes = await Promise.all(videoAttachments.map(async (attachment) => {
|
|
98
|
+
try {
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
100
|
+
console.log(`Uploading video: ${attachment.file_name} (${attachment.file_path})`);
|
|
101
|
+
return await reporter.uploadAttachment(attachment);
|
|
102
|
+
}
|
|
103
|
+
catch (uploadError) {
|
|
104
|
+
console.error(`Failed to upload video ${attachment.file_name}:`, uploadError);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
const validHashes = videoHashes.filter((hash) => hash !== null);
|
|
109
|
+
if (validHashes.length > 0) {
|
|
110
|
+
results.forEach((result) => {
|
|
111
|
+
result.preparedAttachments = validHashes;
|
|
112
|
+
});
|
|
113
|
+
console.log(`Successfully uploaded ${validHashes.length} video files`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.warn('No video files were successfully uploaded');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error('Failed to upload video attachments:', error);
|
|
121
|
+
}
|
|
79
122
|
}
|
|
80
123
|
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
81
124
|
await reporter.setTestResults(results);
|
|
@@ -83,8 +126,4 @@ async function afterSpecHook(spec, options) {
|
|
|
83
126
|
}
|
|
84
127
|
resultsManager_1.ResultsManager.clear();
|
|
85
128
|
}
|
|
86
|
-
|
|
87
|
-
beforeRunHook,
|
|
88
|
-
afterRunHook,
|
|
89
|
-
afterSpecHook,
|
|
90
|
-
};
|
|
129
|
+
exports.afterSpecHook = afterSpecHook;
|
package/dist/options.d.ts
CHANGED
package/dist/reporter.js
CHANGED
|
@@ -209,6 +209,7 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
209
209
|
},
|
|
210
210
|
testops_id: ids.length > 0 ? ids : null,
|
|
211
211
|
title: metadata?.title ?? this.removeQaseIdsFromTitle(test.title),
|
|
212
|
+
preparedAttachments: [],
|
|
212
213
|
};
|
|
213
214
|
void this.reporter.addTestResult(result);
|
|
214
215
|
manager_1.MetadataManager.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-qase-reporter",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
4
|
"description": "Qase Cypress Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"author": "Qase Team <support@qase.io>",
|
|
52
52
|
"license": "Apache-2.0",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"qase-javascript-commons": "~2.
|
|
54
|
+
"qase-javascript-commons": "~2.4.0-beta.1",
|
|
55
55
|
"uuid": "^9.0.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|