@kinora/reporter 0.5.0 → 0.6.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 +20 -0
- package/dist/ct.d.mts +12 -0
- package/dist/ct.mjs +24 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -50,6 +50,26 @@ reporter: [['@kinora/reporter', {
|
|
|
50
50
|
Kinora uploads whatever Playwright attached, so `screenshot: 'only-on-failure'` and
|
|
51
51
|
`video: 'retain-on-failure'` keep deciding what exists in the first place.
|
|
52
52
|
|
|
53
|
+
## Component tests
|
|
54
|
+
|
|
55
|
+
Playwright's built-in component testing (the `mount` fixture, Playwright >=1.63) reports like any
|
|
56
|
+
other test. To let kinora know which story each test mounted, import `test` from
|
|
57
|
+
`@kinora/reporter/ct` instead of `@playwright/test`:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { expect, test } from '@kinora/reporter/ct'
|
|
61
|
+
|
|
62
|
+
test('disabled button is disabled', async ({ mount }) => {
|
|
63
|
+
const component = await mount('components/Button/Disabled')
|
|
64
|
+
await expect(component.getByRole('button')).toBeDisabled()
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Each mounted story id is recorded on the test as a `kinora:story` annotation. Already extending
|
|
69
|
+
`test` with your own fixtures? Extend this one instead: `test.extend({ ... })`.
|
|
70
|
+
|
|
71
|
+
More in the [component testing guide](https://docs.kinora.dev/guides/component-testing/).
|
|
72
|
+
|
|
53
73
|
## Documentation
|
|
54
74
|
|
|
55
75
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kinora/reporter",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.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.
|
|
40
|
+
"@kinora/core": "0.6.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@playwright/test": "^1.63.0",
|