@kinora/reporter 0.5.1 → 0.7.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
@@ -37,8 +37,9 @@ Create an API token in the kinora dashboard (Settings → Workspace). Self-hosti
37
37
 
38
38
  ## Videos and screenshots without tracing
39
39
 
40
- Traces are uploaded by default, and Playwright already embeds a test's screenshots and video
41
- inside its trace.zip. If you run without tracing, upload them on their own:
40
+ Traces are uploaded by default, along with the expected / actual / diff images of a failed
41
+ `toHaveScreenshot`, which kinora shows as a comparison. Playwright already embeds a test's other
42
+ screenshots and its video inside the trace.zip. If you run without tracing, upload them on their own:
42
43
 
43
44
  ```ts
44
45
  reporter: [['@kinora/reporter', {
@@ -50,6 +51,26 @@ reporter: [['@kinora/reporter', {
50
51
  Kinora uploads whatever Playwright attached, so `screenshot: 'only-on-failure'` and
51
52
  `video: 'retain-on-failure'` keep deciding what exists in the first place.
52
53
 
54
+ ## Component tests
55
+
56
+ Playwright's built-in component testing (the `mount` fixture, Playwright >=1.63) reports like any
57
+ other test. To let kinora know which story each test mounted, import `test` from
58
+ `@kinora/reporter/ct` instead of `@playwright/test`:
59
+
60
+ ```ts
61
+ import { expect, test } from '@kinora/reporter/ct'
62
+
63
+ test('disabled button is disabled', async ({ mount }) => {
64
+ const component = await mount('components/Button/Disabled')
65
+ await expect(component.getByRole('button')).toBeDisabled()
66
+ })
67
+ ```
68
+
69
+ Each mounted story id is recorded on the test as a `kinora:story` annotation. Already extending
70
+ `test` with your own fixtures? Extend this one instead: `test.extend({ ... })`.
71
+
72
+ More in the [component testing guide](https://docs.kinora.dev/guides/component-testing/).
73
+
53
74
  ## Documentation
54
75
 
55
76
  Full reporter options, PR/MR comments, CI examples, and self-hosting are in the docs:
package/dist/ct.d.mts ADDED
@@ -0,0 +1,12 @@
1
+ import { TestInfo, expect } from "@playwright/test";
2
+ //#region src/ct.d.ts
3
+ type Annotations = TestInfo['annotations'];
4
+ declare function recordStory(annotations: Annotations, storyId: string): void;
5
+ declare function withStoryAnnotations<M extends (storyId: string, ...rest: any[]) => unknown>(mount: M, annotations: Annotations): M;
6
+ /**
7
+ * Drop-in replacement for `test` from `@playwright/test` in component tests: `mount` records
8
+ * the mounted story id on the test, which lets kinora group results by component and story.
9
+ */
10
+ 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
+ export { expect, recordStory, test, withStoryAnnotations };
package/dist/ct.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import { STORY_ANNOTATION } from "@kinora/core";
2
+ import { expect, test as test$1 } from "@playwright/test";
3
+ //#region src/ct.ts
4
+ function recordStory(annotations, storyId) {
5
+ if (!annotations.some((a) => a.type === STORY_ANNOTATION && a.description === storyId)) annotations.push({
6
+ type: STORY_ANNOTATION,
7
+ description: storyId
8
+ });
9
+ }
10
+ function withStoryAnnotations(mount, annotations) {
11
+ return ((storyId, ...rest) => {
12
+ recordStory(annotations, storyId);
13
+ return mount(storyId, ...rest);
14
+ });
15
+ }
16
+ /**
17
+ * Drop-in replacement for `test` from `@playwright/test` in component tests: `mount` records
18
+ * the mounted story id on the test, which lets kinora group results by component and story.
19
+ */
20
+ const test = test$1.extend({ mount: async ({ mount }, use, testInfo) => {
21
+ await use(withStoryAnnotations(mount, testInfo.annotations));
22
+ } });
23
+ //#endregion
24
+ export { expect, recordStory, test, withStoryAnnotations };
package/dist/index.d.mts CHANGED
@@ -23,7 +23,8 @@ interface KinoraReporterOptions {
23
23
  policy?: 'always' | 'on-failure';
24
24
  };
25
25
  /**
26
- * Which attachment kinds to upload. Defaults to `['trace']`. Add `'video'` / `'screenshot'`
26
+ * Which attachment kinds to upload. Defaults to `['trace', 'snapshot']` (`snapshot` = the images
27
+ * of a failed screenshot assertion, shown as a comparison). Add `'video'` / `'screenshot'`
27
28
  * to host them on their own, which is what you want when `trace` is off (with tracing on,
28
29
  * Playwright already embeds them in the trace.zip).
29
30
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kinora/reporter",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.7.0",
5
5
  "description": "Playwright reporter that uploads test results to a kinora server",
6
6
  "author": "Joris Gallot",
7
7
  "license": "MIT",
@@ -20,7 +20,8 @@
20
20
  "kinora"
21
21
  ],
22
22
  "exports": {
23
- ".": "./dist/index.mjs"
23
+ ".": "./dist/index.mjs",
24
+ "./ct": "./dist/ct.mjs"
24
25
  },
25
26
  "main": "./dist/index.mjs",
26
27
  "files": [
@@ -36,7 +37,7 @@
36
37
  "@playwright/test": ">=1.40.0"
37
38
  },
38
39
  "dependencies": {
39
- "@kinora/core": "0.5.1"
40
+ "@kinora/core": "0.7.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@playwright/test": "^1.63.0",