@kinora/reporter 0.3.0 → 0.5.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kinora/reporter
2
2
 
3
- Playwright reporter that uploads your test results to a [kinora](https://github.com/Kinora-dev/kinora) server: pass rates, trends, flaky tests, and the full Playwright trace for failures, across projects and over time.
3
+ Playwright reporter that uploads your test results to a [kinora](https://github.com/kinora-dev/kinora) server: pass rates, trends, flaky tests, and the full Playwright trace for failures, across projects and over time.
4
4
 
5
5
  It runs on `onEnd`, posts the normalized run, then uploads the trace.zip for each test that produced one (videos and screenshots too, see below). Upload never fails your test run.
6
6
 
@@ -52,7 +52,7 @@ Kinora uploads whatever Playwright attached, so `screenshot: 'only-on-failure'`
52
52
 
53
53
  ## Documentation
54
54
 
55
- Full reporter options, GitHub PR comments, CI examples, and self-hosting are in the docs:
55
+ Full reporter options, PR/MR comments, CI examples, and self-hosting are in the docs:
56
56
 
57
57
  **https://docs.kinora.dev/guides/reporter/**
58
58
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { AttachmentKind, CiMeta, GitMeta } from "@kinora/core";
2
2
  import { FullConfig, FullResult, Reporter, Suite } from "@playwright/test/reporter";
3
-
4
3
  //#region src/index.d.ts
5
4
  interface KinoraReporterOptions {
6
5
  /** kinora server base URL. Defaults to env KINORA_URL, then the hosted cloud. Set for self-host. */
@@ -16,7 +15,8 @@ interface KinoraReporterOptions {
16
15
  ci?: CiMeta;
17
16
  /**
18
17
  * Post/update a summary comment on the GitHub PR (uses the job's GITHUB_TOKEN; needs
19
- * `permissions: pull-requests: write`). `label` distinguishes matrix legs sharing one PR.
18
+ * `permissions: pull-requests: write`) or the GitLab MR (needs a GITLAB_TOKEN CI variable with
19
+ * the `api` scope). `label` distinguishes matrix legs sharing one PR.
20
20
  */
21
21
  prComment?: boolean | {
22
22
  label?: string;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import process from "node:process";
4
- import { DEFAULT_KINORA_URL, DEFAULT_UPLOAD_ATTACHMENTS, IngestError, createIngestClient, effectiveAttachments, isUploadableAttachment, makeTestKey, postPrComment, resolvePrContext } from "@kinora/core";
4
+ import { DEFAULT_KINORA_URL, DEFAULT_UPLOAD_ATTACHMENTS, IngestError, createIngestClient, detectCiEnv, effectiveAttachments, isUploadableAttachment, makeTestKey, postPrComment, resolvePrContext } from "@kinora/core";
5
5
  //#region src/index.ts
6
6
  function identity(test) {
7
7
  let file = "";
@@ -68,29 +68,6 @@ function countsOf(tests) {
68
68
  for (const t of tests) counts[t.status]++;
69
69
  return counts;
70
70
  }
71
- function detectGit() {
72
- const sha = process.env.GITHUB_SHA;
73
- const branch = process.env.GITHUB_REF_NAME;
74
- const baseBranch = process.env.GITHUB_BASE_REF || void 0;
75
- const { GITHUB_SERVER_URL, GITHUB_REPOSITORY } = process.env;
76
- const repoUrl = GITHUB_SERVER_URL && GITHUB_REPOSITORY ? `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}` : void 0;
77
- if (!sha && !branch && !repoUrl) return void 0;
78
- return {
79
- sha,
80
- branch,
81
- baseBranch,
82
- repoUrl
83
- };
84
- }
85
- function detectCi() {
86
- if (!process.env.GITHUB_ACTIONS) return void 0;
87
- const { GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_RUN_NUMBER } = process.env;
88
- return {
89
- provider: "github",
90
- runUrl: GITHUB_SERVER_URL && GITHUB_REPOSITORY && GITHUB_RUN_ID ? `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}` : void 0,
91
- runNumber: GITHUB_RUN_NUMBER
92
- };
93
- }
94
71
  var KinoraReporter = class {
95
72
  options;
96
73
  suite;
@@ -110,6 +87,7 @@ var KinoraReporter = class {
110
87
  return;
111
88
  }
112
89
  const tests = (this.suite?.allTests() ?? []).map(toNormTest);
90
+ const detected = detectCiEnv(process.env);
113
91
  const payload = {
114
92
  project: {
115
93
  slug: this.options.project.slug,
@@ -120,8 +98,8 @@ var KinoraReporter = class {
120
98
  duration: result.duration,
121
99
  counts: countsOf(tests),
122
100
  playwrightVersion: this.config?.version,
123
- git: this.options.git ?? detectGit(),
124
- ci: this.options.ci ?? detectCi()
101
+ git: this.options.git ?? detected.git,
102
+ ci: this.options.ci ?? detected.ci
125
103
  },
126
104
  tests
127
105
  };
@@ -162,10 +140,11 @@ var KinoraReporter = class {
162
140
  const label = typeof opt === "object" ? opt.label : void 0;
163
141
  const policy = typeof opt === "object" ? opt.policy : void 0;
164
142
  try {
165
- const ctx = resolvePrContext(this.config?.shard ? {
143
+ const env = this.config?.shard ? {
166
144
  ...process.env,
167
145
  __KINORA_IS_SHARD: "1"
168
- } : process.env, (p) => {
146
+ } : process.env;
147
+ const ctx = resolvePrContext(env, (p) => {
169
148
  try {
170
149
  return readFileSync(p, "utf8");
171
150
  } catch {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@kinora/reporter",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.5.0",
5
5
  "description": "Playwright reporter that uploads test results to a kinora server",
6
6
  "author": "Joris Gallot",
7
7
  "license": "MIT",
8
- "homepage": "https://github.com/Kinora-dev/kinora#readme",
8
+ "homepage": "https://github.com/kinora-dev/kinora#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/Kinora-dev/kinora.git",
11
+ "url": "git+https://github.com/kinora-dev/kinora.git",
12
12
  "directory": "packages/reporter"
13
13
  },
14
- "bugs": "https://github.com/Kinora-dev/kinora/issues",
14
+ "bugs": "https://github.com/kinora-dev/kinora/issues",
15
15
  "keywords": [
16
16
  "playwright",
17
17
  "reporter",
@@ -36,15 +36,15 @@
36
36
  "@playwright/test": ">=1.40.0"
37
37
  },
38
38
  "dependencies": {
39
- "@kinora/core": "0.3.0"
39
+ "@kinora/core": "0.5.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@playwright/test": "^1.61.0",
43
- "@types/node": "^26.0.0",
44
- "@vitest/coverage-v8": "^4.1.9",
45
- "tsdown": "^0.22.3",
42
+ "@playwright/test": "^1.63.0",
43
+ "@types/node": "^26.5.1",
44
+ "@vitest/coverage-v8": "^4.1.11",
45
+ "tsdown": "^0.22.14",
46
46
  "typescript": "~6.0.3",
47
- "vitest": "^4.1.9"
47
+ "vitest": "^4.1.11"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown",