@isummation/kasauti-playwright-reporter 0.2.0 → 0.4.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.
Files changed (2) hide show
  1. package/README.md +85 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,17 +1,96 @@
1
1
  # @isummation/kasauti-playwright-reporter
2
2
 
3
- Sends Playwright results to [Kasauti](https://gitlab.isummation.com/isummation-product/kasauti), with the screenshots, videos and traces Playwright keeps and anything tests attach. No dependencies.
3
+ Sends Playwright test results to **Kasauti** test management after each run, with the screenshots, videos and traces Playwright keeps and anything your tests attach. Each run becomes a Kasauti test run; each test lands on its test case. No dependencies; needs `@playwright/test` 1.40 or later.
4
+
5
+ ## Install
4
6
 
5
7
  ```bash
6
- npm install -D @isummation/kasauti-playwright-reporter # needs access to the @isummation npm org
8
+ npm install -D @isummation/kasauti-playwright-reporter
7
9
  ```
8
10
 
11
+ ## Configure
12
+
9
13
  ```ts
10
14
  // playwright.config.ts
11
- reporter: [['list'], ['@isummation/kasauti-playwright-reporter', { project: 'SHOP' }]],
12
- use: { screenshot: 'only-on-failure', video: 'retain-on-failure', trace: 'retain-on-failure' },
15
+ import { defineConfig } from '@playwright/test';
16
+
17
+ export default defineConfig({
18
+ reporter: [['list'], ['@isummation/kasauti-playwright-reporter', { project: 'SHOP' }]],
19
+ // what Playwright keeps is what gets uploaded
20
+ use: { screenshot: 'only-on-failure', video: 'retain-on-failure', trace: 'retain-on-failure' },
21
+ });
22
+ ```
23
+
24
+ Then give it the Kasauti API URL and a token (from the Kasauti web app, **Settings → API tokens & agents**; a personal token of a tester or a dedicated CI user):
25
+
26
+ ```bash
27
+ export KASAUTI_URL=https://kasauti-api.your-company.com
28
+ export KASAUTI_TOKEN=<token>
29
+ ```
30
+
31
+ Without a token the reporter prints `reporting disabled` and does nothing else, so local runs work without setup.
32
+
33
+ | Option | Environment variable | Default | Meaning |
34
+ |---|---|---|---|
35
+ | `url` | `KASAUTI_URL` | `http://localhost:3001` | Kasauti API address |
36
+ | `token` | `KASAUTI_TOKEN` | none (reporting disabled) | API token |
37
+ | `project` | `KASAUTI_PROJECT` | none (reporting disabled) | Project code, e.g. `SHOP` |
38
+ | `title` | `KASAUTI_RUN_TITLE` | `Playwright <date time>` | Title of the run it creates |
39
+ | `run` | `KASAUTI_RUN` | none | Report into this existing run (e.g. `SHOP-R5`) instead of creating one; it is left open |
40
+ | | `KASAUTI_ENV` | none | Environment shown on the run, e.g. `staging` |
41
+
42
+ Options in the config win over environment variables. Keep the token in the environment, not in the config file.
43
+
44
+ ## Link tests to test cases
45
+
46
+ - Put the case key in the test title: `test('wrong password shows an error @SHOP-12', …)`. The result goes to that case.
47
+ - Or use an annotation: `test('…', { annotation: { type: 'kasauti', description: 'SHOP-12' } }, …)`.
48
+ - Untagged tests are matched by file, `describe` blocks and title. The first time, Kasauti creates a **draft** case for each, for a tester to review and approve.
49
+
50
+ Playwright's statuses map to Kasauti's: passed → passed, failed and timed out → failed, interrupted → blocked, skipped → skipped. With retries, only the last attempt is recorded. Failure messages and stack traces go into the result.
51
+
52
+ ## Evidence
53
+
54
+ Screenshots, videos and traces that Playwright keeps (see `use` above) upload with the result. So does anything a test attaches:
55
+
56
+ ```ts
57
+ test('cart total @SHOP-14', async ({ page }, testInfo) => {
58
+ await testInfo.attach('cart', { body: await page.screenshot(), contentType: 'image/png' });
59
+ await testInfo.attach('api-response', { body: JSON.stringify(data), contentType: 'application/json' });
60
+ });
61
+ ```
62
+
63
+ Up to 10 files per result, 20 MB each; larger files are skipped with a warning. Results are sent in batches sized to stay under the API's request limit.
64
+
65
+ ## In CI
66
+
67
+ Store `KASAUTI_URL` and `KASAUTI_TOKEN` as secret CI variables. GitLab CI:
68
+
69
+ ```yaml
70
+ e2e:
71
+ image: mcr.microsoft.com/playwright:v1.64.1-noble # match your @playwright/test version
72
+ script:
73
+ - npm ci
74
+ - KASAUTI_RUN_TITLE="CI $CI_COMMIT_REF_NAME $CI_COMMIT_SHORT_SHA" KASAUTI_ENV="$CI_ENVIRONMENT_NAME" npx playwright test
75
+ ```
76
+
77
+ GitHub Actions:
78
+
79
+ ```yaml
80
+ - run: npx playwright test
81
+ env:
82
+ KASAUTI_URL: ${{ secrets.KASAUTI_URL }}
83
+ KASAUTI_TOKEN: ${{ secrets.KASAUTI_TOKEN }}
84
+ KASAUTI_RUN_TITLE: CI ${{ github.ref_name }} ${{ github.sha }}
13
85
  ```
14
86
 
15
- Tag tests with case keys (`test('pays by card @SHOP-12', …)`); untagged tests become draft cases on first run. Set `KASAUTI_URL` and `KASAUTI_TOKEN`; optional `KASAUTI_RUN_TITLE`, `KASAUTI_ENV`, `KASAUTI_RUN`. Without a token it does nothing. Files over 20 MB are skipped.
87
+ ## Troubleshooting
16
88
 
17
- Full guide: `docs/using-kasauti-in-your-project.md` in the Kasauti repository.
89
+ | What you see | Fix |
90
+ |---|---|
91
+ | `[kasauti] KASAUTI_TOKEN and project are required; reporting disabled` | Set `KASAUTI_TOKEN`, and `project` in the config (or `KASAUTI_PROJECT`). |
92
+ | `[kasauti] Kasauti POST /runs → 401` | The token is wrong, revoked, or from a different Kasauti server. |
93
+ | `… → 404` | Wrong project code, or the token's user isn't assigned to the project. |
94
+ | `… → 403` | The token's user can't record results (a developer). Use a tester's or CI user's token. |
95
+ | `[kasauti] skipped <file> (… MB; the limit is 20 MB)` | Lower video size or retention (`video: 'retain-on-failure'`), or attach less. |
96
+ | Results land on new draft cases instead of existing ones | Tag the tests with the case keys. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isummation/kasauti-playwright-reporter",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Send Playwright results, with screenshots, videos and traces, to Kasauti",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
@@ -21,7 +21,7 @@
21
21
  "directory": "packages/playwright-reporter"
22
22
  },
23
23
  "publishConfig": {
24
- "access": "restricted",
24
+ "access": "public",
25
25
  "registry": "https://registry.npmjs.org/"
26
26
  }
27
27
  }