@kinora/reporter 0.10.0 → 0.12.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/a11y.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Page } from "@playwright/test";
2
2
  import AxeBuilder from "@axe-core/playwright";
3
- //#region src/a11y.d.ts
4
3
  export type AxeResults = Awaited<ReturnType<AxeBuilder['analyze']>>;
5
4
  export declare const A11Y_ATTACHMENT = "accessibility-scan-results";
6
5
  /**
@@ -11,5 +10,4 @@ export declare const A11Y_ATTACHMENT = "accessibility-scan-results";
11
10
  * record them as warnings. `configure` narrows or widens the scan, e.g.
12
11
  * `axe => axe.withTags(['wcag2a', 'wcag2aa'])`.
13
12
  */
14
- export declare function scanA11y(page: Page, configure?: (axe: AxeBuilder) => AxeBuilder): Promise<AxeResults>;
15
- //#endregion
13
+ export declare function scanA11y(page: Page, configure?: (axe: AxeBuilder) => AxeBuilder): Promise<AxeResults>;
package/dist/a11y.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/test";
2
- //#region src/a11y.ts
2
+ // src/a11y.ts
3
3
  const A11Y_ATTACHMENT = "accessibility-scan-results";
4
4
  /**
5
5
  * Scans the page with axe (`@axe-core/playwright`) and attaches the result to the running test,
@@ -21,5 +21,4 @@ async function scanA11y(page, configure) {
21
21
  });
22
22
  return results;
23
23
  }
24
- //#endregion
25
24
  export { A11Y_ATTACHMENT, scanA11y };
package/dist/ct.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { TestInfo, expect } from "@playwright/test";
2
- //#region src/ct.d.ts
3
2
  type Annotations = TestInfo['annotations'];
4
3
  export declare function recordStory(annotations: Annotations, storyId: string): void;
5
4
  export declare function withStoryAnnotations<M extends (storyId: string, ...rest: any[]) => unknown>(mount: M, annotations: Annotations): M;
@@ -8,5 +7,4 @@ export declare function withStoryAnnotations<M extends (storyId: string, ...rest
8
7
  * the mounted story id on the test, which lets kinora group results by component and story.
9
8
  */
10
9
  export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
11
- //#endregion
12
10
  export { expect };
package/dist/ct.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { STORY_ANNOTATION } from "@kinora/core";
2
2
  import { expect, test as test$1 } from "@playwright/test";
3
- //#region src/ct.ts
3
+ // src/ct.ts
4
4
  function recordStory(annotations, storyId) {
5
5
  if (!annotations.some((a) => a.type === STORY_ANNOTATION && a.description === storyId)) annotations.push({
6
6
  type: STORY_ANNOTATION,
@@ -20,5 +20,4 @@ function withStoryAnnotations(mount, annotations) {
20
20
  const test = test$1.extend({ mount: async ({ mount }, use, testInfo) => {
21
21
  await use(withStoryAnnotations(mount, testInfo.annotations));
22
22
  } });
23
- //#endregion
24
23
  export { expect, recordStory, test, withStoryAnnotations };
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
- //#region src/index.d.ts
4
3
  export interface KinoraReporterOptions {
5
4
  /** kinora server base URL. Defaults to env KINORA_URL, then the hosted cloud. Set for self-host. */
6
5
  url?: string;
@@ -29,6 +28,12 @@ export interface KinoraReporterOptions {
29
28
  * Playwright already embeds them in the trace.zip).
30
29
  */
31
30
  uploadAttachments?: AttachmentKind[];
31
+ /**
32
+ * Sharded runs (`--shard`): the uploads of every shard of one CI run are assembled into a single
33
+ * kinora run. Shards are grouped by this key, defaulting to env KINORA_GROUP_KEY, then the CI run
34
+ * (GITHUB_RUN_ID / CI_PIPELINE_ID). `false` uploads each shard as its own run.
35
+ */
36
+ groupKey?: string | false;
32
37
  }
33
38
  export default class KinoraReporter implements Reporter {
34
39
  private readonly options;
@@ -37,6 +42,6 @@ export default class KinoraReporter implements Reporter {
37
42
  constructor(options: KinoraReporterOptions);
38
43
  onBegin(config: FullConfig, suite: Suite): void;
39
44
  onEnd(result: FullResult): Promise<void>;
45
+ private prCommentLabel;
40
46
  private maybePostPrComment;
41
- }
42
- //#endregion
47
+ }
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
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, detectCiEnv, effectiveAttachments, flakyTestsOf, isUploadableAttachment, makeTestKey, parseAxeScan, postPrComment, resolvePrContext } from "@kinora/core";
5
- //#region src/index.ts
4
+ import { DEFAULT_KINORA_URL, DEFAULT_UPLOAD_ATTACHMENTS, IngestError, a11yFromScans, createIngestClient, describeRetry, detectCiEnv, effectiveAttachments, flakyTestsOf, isUploadableAttachment, makeTestKey, parseAxeScan, postPrComment, resolvePrContext, resolveShardGroup } from "@kinora/core";
5
+ // src/index.ts
6
6
  function identity(test) {
7
7
  let file = "";
8
8
  let projectName = "";
@@ -104,6 +104,11 @@ 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;
108
+ const group = shard && this.options.groupKey !== false ? resolveShardGroup(process.env, {
109
+ groupKey: this.options.groupKey,
110
+ leg: this.prCommentLabel()
111
+ }) : void 0;
107
112
  const payload = {
108
113
  project: {
109
114
  slug: this.options.project.slug,
@@ -115,7 +120,14 @@ var KinoraReporter = class {
115
120
  counts: countsOf(tests),
116
121
  playwrightVersion: this.config?.version,
117
122
  git: this.options.git ?? detected.git,
118
- ci: this.options.ci ?? detected.ci
123
+ ci: this.options.ci ?? detected.ci,
124
+ ...shard && group && {
125
+ ...group,
126
+ shard: {
127
+ current: shard.current,
128
+ total: shard.total
129
+ }
130
+ }
119
131
  },
120
132
  tests
121
133
  };
@@ -123,7 +135,8 @@ var KinoraReporter = class {
123
135
  const client = createIngestClient({
124
136
  baseUrl: url,
125
137
  token,
126
- regression: !!this.options.prComment
138
+ regression: !!this.options.prComment,
139
+ onRetry: (info) => console.warn(`[kinora] ${describeRetry(info)}`)
127
140
  });
128
141
  const res = await client.uploadRun(payload);
129
142
  const kinds = this.options.uploadAttachments ?? DEFAULT_UPLOAD_ATTACHMENTS;
@@ -143,20 +156,26 @@ var KinoraReporter = class {
143
156
  console.warn(`[kinora] ${a.name} upload failed for ${t.testKey}:`, err instanceof Error ? err.message : err);
144
157
  }
145
158
  }
146
- console.log(`[kinora] uploaded ${res.tests} tests + ${artifacts} artifacts (run ${res.runId})`);
159
+ console.log(`[kinora] uploaded ${res.tests} tests + ${artifacts} artifacts (run ${res.runId}${res.shardProgress ? `, ${res.shardProgress.landed} of ${res.shardProgress.total} shards` : ""})`);
147
160
  await this.maybePostPrComment(payload, res);
148
161
  } catch (err) {
149
162
  if (err instanceof IngestError && err.status === 402) console.warn(`[kinora] ${err.message}`);
150
163
  else console.error(`[kinora] upload failed:`, err instanceof Error ? err.message : err);
151
164
  }
152
165
  }
166
+ prCommentLabel() {
167
+ const opt = this.options.prComment;
168
+ return typeof opt === "object" ? opt.label : void 0;
169
+ }
153
170
  async maybePostPrComment(payload, res) {
154
171
  if (!this.options.prComment) return;
155
172
  const opt = this.options.prComment;
156
- const label = typeof opt === "object" ? opt.label : void 0;
173
+ const label = this.prCommentLabel();
157
174
  const policy = typeof opt === "object" ? opt.policy : void 0;
175
+ const grouped = !!payload.run.groupKey;
176
+ if (grouped && !res.shardProgress) return;
158
177
  try {
159
- const env = this.config?.shard ? {
178
+ const env = this.config?.shard && !grouped ? {
160
179
  ...process.env,
161
180
  __KINORA_IS_SHARD: "1"
162
181
  } : process.env;
@@ -174,9 +193,13 @@ var KinoraReporter = class {
174
193
  label,
175
194
  runUrl: res.runUrl,
176
195
  ciRunUrl: payload.run.ci?.runUrl,
177
- counts: payload.run.counts,
196
+ counts: res.counts ?? payload.run.counts,
178
197
  regression: res.regression,
179
- flaky: flakyTestsOf(payload.tests)
198
+ flaky: res.flaky ?? flakyTestsOf(payload.tests),
199
+ ...res.shardProgress && { shards: {
200
+ runId: res.runId,
201
+ ...res.shardProgress
202
+ } }
180
203
  }, policy ?? "always");
181
204
  if (outcome !== "skipped") console.warn(`[kinora] PR comment ${outcome}`);
182
205
  } catch (err) {
@@ -184,5 +207,4 @@ var KinoraReporter = class {
184
207
  }
185
208
  }
186
209
  };
187
- //#endregion
188
210
  export { KinoraReporter as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kinora/reporter",
3
3
  "type": "module",
4
- "version": "0.10.0",
4
+ "version": "0.12.0",
5
5
  "description": "Playwright reporter that uploads test results to a kinora server",
6
6
  "author": "Joris Gallot",
7
7
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "peerDependencies": {
38
- "@axe-core/playwright": ">=4.7.0",
38
+ "@axe-core/playwright": ">=4.14.0",
39
39
  "@playwright/test": ">=1.40.0"
40
40
  },
41
41
  "peerDependenciesMeta": {
@@ -44,16 +44,16 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "@kinora/core": "0.12.0"
47
+ "@kinora/core": "0.14.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@axe-core/playwright": "^4.13.0",
51
- "@playwright/test": "^1.64.0",
50
+ "@axe-core/playwright": "^4.14.0",
51
+ "@playwright/test": "^1.64.1",
52
52
  "@types/node": "^26.6.5",
53
- "@vitest/coverage-v8": "^5.0.4",
54
- "tsdown": "^0.23.1",
53
+ "@vitest/coverage-v8": "^5.0.5",
54
+ "tsdown": "^0.23.2",
55
55
  "typescript": "~6.0.3",
56
- "vitest": "^5.0.4"
56
+ "vitest": "^5.0.5"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsdown",