@kinora/reporter 0.13.0 → 0.15.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/dist/index.d.mts CHANGED
@@ -42,6 +42,7 @@ export default class KinoraReporter implements Reporter {
42
42
  constructor(options: KinoraReporterOptions);
43
43
  onBegin(config: FullConfig, suite: Suite): void;
44
44
  onEnd(result: FullResult): Promise<void>;
45
+ private shard;
45
46
  private prCommentLabel;
46
47
  private maybePostPrComment;
47
48
  }
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, statSync } 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, a11yFromScans, createIngestClient, describeRetry, detectCiEnv, effectiveAttachments, flakyTestsOf, isUploadableAttachment, makeTestKey, parseAxeScan, postPrComment, resolvePrContext, resolveShardGroup } from "@kinora/core";
4
+ import { DEFAULT_KINORA_URL, DEFAULT_UPLOAD_ATTACHMENTS, IngestError, a11yFromScans, artifactsToUpload, createIngestClient, describeRetry, detectCiEnv, effectiveAttachments, flakyTestsOf, makeTestKey, parseAxeScan, postPrComment, resolvePrContext, resolveShardGroup, shardFromEnv, uploadArtifacts } from "@kinora/core";
5
5
  // src/index.ts
6
6
  function identity(test) {
7
7
  let file = "";
@@ -104,7 +104,7 @@ var KinoraReporter = class {
104
104
  }
105
105
  const tests = (this.suite?.allTests() ?? []).map(toNormTest);
106
106
  const detected = detectCiEnv(process.env);
107
- const shard = this.config?.shard;
107
+ const shard = this.shard();
108
108
  const group = shard && this.options.groupKey !== false ? resolveShardGroup(process.env, {
109
109
  groupKey: this.options.groupKey,
110
110
  leg: this.prCommentLabel()
@@ -141,23 +141,10 @@ var KinoraReporter = class {
141
141
  onRetry: (info) => console.warn(`[kinora] ${describeRetry(info)}`)
142
142
  });
143
143
  const res = await client.uploadRun(payload);
144
- const kinds = this.options.uploadAttachments ?? DEFAULT_UPLOAD_ATTACHMENTS;
145
- let artifacts = 0;
146
- for (const t of tests) for (const a of t.attachments) {
147
- if (!a.path || !isUploadableAttachment(a, kinds)) continue;
148
- try {
149
- await client.uploadArtifact({
150
- runId: res.runId,
151
- testKey: t.testKey,
152
- name: a.name,
153
- contentType: a.contentType,
154
- body: await readFile(a.path)
155
- });
156
- artifacts++;
157
- } catch (err) {
158
- console.warn(`[kinora] ${a.name} upload failed for ${t.testKey}:`, err instanceof Error ? err.message : err);
159
- }
160
- }
144
+ const artifacts = await uploadArtifacts(client, res.runId, artifactsToUpload(tests, this.options.uploadAttachments ?? DEFAULT_UPLOAD_ATTACHMENTS), {
145
+ read: readFile,
146
+ onFailed: (a, err) => console.warn(`[kinora] ${a.name} upload failed for ${a.testKey}:`, err instanceof Error ? err.message : err)
147
+ });
161
148
  console.log(`[kinora] uploaded ${res.tests} tests + ${artifacts} artifacts (run ${res.runId}${res.shardProgress ? `, ${res.shardProgress.landed} of ${res.shardProgress.total} shards` : ""})`);
162
149
  if (res.incident) console.warn(`[kinora] environment incident, not counted: ${res.incident.reason}`);
163
150
  await this.maybePostPrComment(payload, res);
@@ -166,6 +153,9 @@ var KinoraReporter = class {
166
153
  else console.error(`[kinora] upload failed:`, err instanceof Error ? err.message : err);
167
154
  }
168
155
  }
156
+ shard() {
157
+ return this.config?.shard ?? shardFromEnv(process.env);
158
+ }
169
159
  prCommentLabel() {
170
160
  const opt = this.options.prComment;
171
161
  return typeof opt === "object" ? opt.label : void 0;
@@ -178,7 +168,7 @@ var KinoraReporter = class {
178
168
  const grouped = !!payload.run.groupKey;
179
169
  if (grouped && !res.shardProgress) return;
180
170
  try {
181
- const env = this.config?.shard && !grouped ? {
171
+ const env = this.shard() && !grouped ? {
182
172
  ...process.env,
183
173
  __KINORA_IS_SHARD: "1"
184
174
  } : process.env;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kinora/reporter",
3
3
  "type": "module",
4
- "version": "0.13.0",
4
+ "version": "0.15.0",
5
5
  "description": "Playwright reporter that uploads test results to a kinora server",
6
6
  "author": "Joris Gallot",
7
7
  "license": "MIT",
@@ -45,16 +45,16 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@kinora/core": "0.15.0"
48
+ "@kinora/core": "0.17.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@axe-core/playwright": "^4.14.0",
52
- "@playwright/test": "^1.64.1",
53
- "@types/node": "^26.6.5",
54
- "@vitest/coverage-v8": "^5.0.5",
55
- "tsdown": "^0.23.3",
52
+ "@playwright/test": "^1.65.0",
53
+ "@types/node": "^26.6.6",
54
+ "@vitest/coverage-v8": "^5.1.0",
55
+ "tsdown": "^0.23.7",
56
56
  "typescript": "~6.0.3",
57
- "vitest": "^5.0.5"
57
+ "vitest": "^5.1.0"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "tsdown",