playwright-zephyr-junit-reporter 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 abautu@gmail.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # playwright-zephyr-junit-reporter
2
+
3
+ A [Playwright](https://playwright.dev/) reporter that imports JUnit test results into [Zephyr Squad for Jira Cloud](https://zephyrdocs.atlassian.net/wiki/spaces/ZFJCLOUD/pages/1686798372/Test+Automation+API+Documentation) via the Test Automation API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install --save-dev playwright-zephyr-junit-reporter
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Add both the built-in `junit` reporter and this reporter to your `playwright.config.js`. Both must point to the same output file — this reporter reads the file that `junit` writes.
14
+
15
+ ```js
16
+ // playwright.config.js
17
+ export default {
18
+ reporter: [
19
+ ['junit', { stripANSIControlSequences: true, outputFile: './playwright-report/junit/results.xml' }],
20
+ ['playwright-zephyr-junit-reporter', {
21
+ projectKey: process.env.ZEPHYR_PROJECT_KEY,
22
+ accountId: process.env.ZEPHYR_ACCOUNT_ID,
23
+ accessKey: process.env.ZEPHYR_ACCESS_KEY,
24
+ secretKey: process.env.ZEPHYR_SECRET_KEY,
25
+ jUnitFile: './playwright-report/junit/results.xml',
26
+ }],
27
+ ],
28
+ };
29
+ ```
30
+
31
+ ## Configuration
32
+
33
+ | Option | Type | Required | Default | Description |
34
+ |---|---|---|---|---|
35
+ | `projectKey` | `string` | yes | — | Jira project key (e.g. `PROJ`) |
36
+ | `accountId` | `string` | yes | — | Jira account ID of the user running the import |
37
+ | `accessKey` | `string` | yes | — | Zephyr Squad access key |
38
+ | `secretKey` | `string` | yes | — | Zephyr Squad secret key |
39
+ | `jUnitFile` | `string` | yes | — | Path to the JUnit XML results file |
40
+ | `jobName` | `string` | no | `"Import tests results"` | Display name for the automation job |
41
+ | `jobDescription` | `string` | no | `"Import automatic tests results from JUnit file."` | Description for the automation job |
42
+ | `cycleName` | `string` | no | `"Playwright tests"` | Test cycle name in Zephyr (current date/time is appended automatically) |
43
+ | `versionName` | `string` | no | `"Unscheduled"` | Zephyr version/fix version name |
44
+ | `timeOut` | `number` | no | `300000` | Upload job timeout in milliseconds |
45
+
46
+ ### Obtaining credentials
47
+
48
+ - **`accessKey` / `secretKey`**: Generated in Jira under **Apps → Zephyr Squad → API Keys**.
49
+ - **`accountId`**: Your Atlassian account ID, visible in your Jira profile URL or via the Jira REST API.
50
+
51
+ ## License
52
+
53
+ MIT
@@ -0,0 +1,41 @@
1
+ import type { FullResult, Reporter } from '@playwright/test/reporter';
2
+ /**
3
+ * Options for {@link ZephyrJUnitImportReporter}.
4
+ */
5
+ export interface ZephyrJUnitImportReporterOptions {
6
+ /** Jira project key (e.g. `"PROJ"`). */
7
+ projectKey: string;
8
+ /** Jira account ID of the user running the import. */
9
+ accountId: string;
10
+ /** Zephyr Squad access key. */
11
+ accessKey: string;
12
+ /** Zephyr Squad secret key. */
13
+ secretKey: string;
14
+ /** Path to the JUnit XML results file. */
15
+ jUnitFile: string;
16
+ /** Upload job timeout in ms. Defaults to 5 minutes. */
17
+ timeOut?: number;
18
+ /** Display name for the automation job. */
19
+ jobName?: string;
20
+ /** Description for the automation job. */
21
+ jobDescription?: string;
22
+ /** Test cycle name in Zephyr. Defaults to `"Playwright tests"`. */
23
+ cycleName?: string;
24
+ /** Zephyr version/fix version name. Defaults to `"Unscheduled"`. */
25
+ versionName?: string;
26
+ }
27
+ declare class ZephyrJUnitImportReporter implements Reporter {
28
+ private projectKey;
29
+ private accountId;
30
+ private accessKey;
31
+ private secretKey;
32
+ private jUnitFile;
33
+ private timeOut;
34
+ private jobName;
35
+ private jobDescription;
36
+ private cycleName;
37
+ private versionName;
38
+ constructor(options: ZephyrJUnitImportReporterOptions);
39
+ onEnd(_result: FullResult): Promise<void>;
40
+ }
41
+ export default ZephyrJUnitImportReporter;
package/dist/index.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_1 = require("@playwright/test");
4
+ const fs_1 = require("fs");
5
+ // See https://zephyrdocs.atlassian.net/wiki/spaces/ZFJCLOUD/pages/1686798372/Test+Automation+API+Documentation
6
+ const ZEPHYR_BASE_URL = 'https://prod-vortexapi.zephyr4jiracloud.com/';
7
+ class ZephyrJUnitImportReporter {
8
+ constructor(options) {
9
+ this.projectKey = options.projectKey;
10
+ this.accountId = options.accountId;
11
+ this.accessKey = options.accessKey;
12
+ this.secretKey = options.secretKey;
13
+ this.jUnitFile = options.jUnitFile;
14
+ this.timeOut = options.timeOut || 5 * 60000;
15
+ this.jobName = options.jobName || 'Import tests results';
16
+ this.jobDescription = options.jobDescription || 'Import automatic tests results from JUnit file.';
17
+ this.cycleName = options.cycleName || 'Playwright tests';
18
+ this.versionName = options.versionName || 'Unscheduled';
19
+ }
20
+ async onEnd(_result) {
21
+ let jUnitBuffer;
22
+ try {
23
+ jUnitBuffer = (0, fs_1.readFileSync)(this.jUnitFile);
24
+ }
25
+ catch {
26
+ throw new Error(`JUnit file not found: ${this.jUnitFile}`);
27
+ }
28
+ const client = await test_1.request.newContext({ baseURL: ZEPHYR_BASE_URL });
29
+ try {
30
+ let response;
31
+ response = await client.post('api/v1/jwt/generate', {
32
+ data: {
33
+ accessKey: this.accessKey,
34
+ secretKey: this.secretKey,
35
+ accountId: this.accountId,
36
+ },
37
+ });
38
+ if (!response.ok()) {
39
+ throw new Error(`Failed to generate JWT: ${await response.text()}`);
40
+ }
41
+ const jwt = await response.text();
42
+ console.log('Create and execute an upload job for Zephyr test automation.');
43
+ response = await client.post('api/v1/automation/job/saveAndExecute', {
44
+ headers: {
45
+ accessKey: this.accessKey,
46
+ jwt: jwt,
47
+ },
48
+ multipart: {
49
+ projectKey: this.projectKey,
50
+ jobName: this.jobName,
51
+ jobDescription: this.jobDescription,
52
+ automationFramework: 'JUNIT',
53
+ createNewCycle: true,
54
+ cycleName: this.cycleName,
55
+ appendDateTimeInCycleName: true,
56
+ versionName: this.versionName,
57
+ file: {
58
+ name: 'results.xml',
59
+ mimeType: 'text/xml',
60
+ buffer: jUnitBuffer,
61
+ },
62
+ assigneeUser: this.accountId,
63
+ mandatoryFields: JSON.stringify({
64
+ reporter: {
65
+ id: this.accountId,
66
+ },
67
+ }),
68
+ },
69
+ timeout: this.timeOut,
70
+ });
71
+ if (!response.ok()) {
72
+ throw new Error(`Failed to create upload test automation: ${await response.text()}`);
73
+ }
74
+ console.log('Response: ' + (await response.json()).message);
75
+ }
76
+ finally {
77
+ await client.dispose();
78
+ }
79
+ }
80
+ }
81
+ exports.default = ZephyrJUnitImportReporter;
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "playwright-zephyr-junit-reporter",
3
+ "version": "1.0.0",
4
+ "description": "Playwright reporter that imports JUnit test results to Zephyr Squad (Zephyr for Jira Cloud) via the Test Automation API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "peerDependencies": {
15
+ "@playwright/test": ">=1.0.0"
16
+ },
17
+ "keywords": [
18
+ "playwright",
19
+ "zephyr",
20
+ "zephyr-squad",
21
+ "zephyr-for-jira",
22
+ "junit",
23
+ "reporter",
24
+ "test-automation"
25
+ ],
26
+ "author": "abautu@gmail.com",
27
+ "license": "MIT",
28
+ "devDependencies": {
29
+ "@playwright/test": "^1.59.1",
30
+ "@types/node": "^25.6.2",
31
+ "typescript": "^6.0.3"
32
+ }
33
+ }