@flakemetry/wdio-reporter 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +95 -2
- package/dist/index.cjs +640 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +157 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +611 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrii Kohut
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,96 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @flakemetry/wdio-reporter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
WebdriverIO reporter for [Flakemetry](https://github.com/AKogut/flakemetry). It records every attempt of every test, so a test rescued by a retry reads as flaky, gives each capability its own history, and turns WebdriverIO commands into a trace.
|
|
4
|
+
|
|
5
|
+
It supports WebdriverIO 9 and 10 (`@wdio/cli` `^9.0.0 || ^10.0.0`) with the Mocha and Jasmine frameworks, on Node 22.15 or later.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i -D @flakemetry/wdio-reporter
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// wdio.conf.ts
|
|
17
|
+
export const config: WebdriverIO.Config = {
|
|
18
|
+
reporters: ['spec', '@flakemetry/wdio-reporter'],
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Set the endpoint and token in CI:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
FLAKEMETRY_ENDPOINT=https://ingest.example.com
|
|
26
|
+
FLAKEMETRY_TOKEN=fmk_...
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The reporter derives commit, branch, PR number and CI run id from the environment and sends each worker's results when the worker finishes. A delivery problem never fails the run.
|
|
30
|
+
|
|
31
|
+
## What it records
|
|
32
|
+
|
|
33
|
+
- **Every attempt.** Mocha retries, from `this.retries()` or `mochaOpts.retries`, arrive as separate attempts. A test that fails and then passes is recorded as flaky, with the pass linked to its first attempt.
|
|
34
|
+
- **The whole failure.** The error message is kept up to the stack, so `toHaveText` failures with different expected values do not share one error signature.
|
|
35
|
+
- **Hooks.** A `before` or `after` hook that fails is recorded as a failed execution named after the hook. A test that never ran because of it is skipped, not failed, so its pass on the next run is not called flaky. WebdriverIO 9 sends no event for the tests a failed `before all` hook stopped, so those are missing from the run rather than skipped.
|
|
36
|
+
- **Commands as spans.** Every WebdriverIO command between the start and the end of a test becomes a span with its name, timing and status, so the test has a trace in the dashboard. An `expect-webdriverio` assertion is a step, with the commands it polled under it, and a passing `beforeEach` hook is a step with its own commands. An execution keeps up to 500 spans.
|
|
37
|
+
- **A variant per capability.** When the config runs more than one capability, each test gets its capability as the variant, so a test that fails only on Android reads as an Android failure. The variant is the capability's `flakemetry:variant` if it has one, otherwise its `platformName` with its `browserName` or `appium:deviceName`: `Android Pixel 8`, `iOS iPhone 15`, `chrome`. Two capabilities that read the same get their position, `chrome (2)`. A config with one capability gets no variant, so identities recorded through JUnit or Allure stay as they are. `FLAKEMETRY_VARIANT` goes in front, `nightly/Android Pixel 8`, as it does for every reporter.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
capabilities: [
|
|
41
|
+
{ platformName: 'Android', 'appium:deviceName': 'Pixel 8', 'flakemetry:variant': 'android-14' },
|
|
42
|
+
{ platformName: 'iOS', 'appium:deviceName': 'iPhone 15', 'flakemetry:variant': 'ios-17' },
|
|
43
|
+
]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`flakemetry:variant` is a W3C extension capability, sent to the driver with the rest. Chromedriver accepts it. A grid or server that refuses capabilities it does not know can take `FLAKEMETRY_VARIANT` from each job instead.
|
|
47
|
+
|
|
48
|
+
## One batch per worker
|
|
49
|
+
|
|
50
|
+
WebdriverIO runs each spec file of each capability in a worker of its own, with its own reporter. Each worker sends its own batch under its own idempotency key, so a run of 40 spec files on two devices arrives as 80 batches of one CI run, and none replaces another.
|
|
51
|
+
|
|
52
|
+
WebdriverIO waits for a worker's upload before the worker exits, for up to `reporterSyncTimeout`, 5 seconds by default. Raise it if your uploads take longer:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
export const config: WebdriverIO.Config = {
|
|
56
|
+
reporterSyncTimeout: 30_000,
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
When `FLAKEMETRY_OUTPUT_FILE` or the `outputFile` option is set, each worker writes its batch to its own file, with the worker id in the name: `flakemetry-results.json` becomes `flakemetry-results-0-0.json`, `flakemetry-results-1-0.json` and so on. The file is written before the upload starts. To upload the files in a later step, send each one with the CLI. The GitHub Action uploads one file per step, so use the loop:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
for file in flakemetry-results-*.json; do
|
|
64
|
+
npx @flakemetry/cli upload "$file"
|
|
65
|
+
done
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## What it cannot see
|
|
69
|
+
|
|
70
|
+
- Jasmine has no retries of its own. WebdriverIO's repeat argument, `it('...', fn, timeout, 2)`, runs the function again inside one test and tells no reporter about the failed tries, so such a test arrives as one pass. The same holds for that argument under Mocha.
|
|
71
|
+
- `specFileRetries` runs the spec file again in a new worker, and each attempt is a batch of its own.
|
|
72
|
+
- A multiremote run drives every browser from one worker, so it gets no capability variant.
|
|
73
|
+
- The reporter learns how many capabilities the config runs by reading the config file the runner loaded: the path given to `wdio run`, or `wdio.conf.ts` or `wdio.conf.js` in the working directory. If WebdriverIO is started some other way, give each capability a `flakemetry:variant`.
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
| Variable | Effect |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `FLAKEMETRY_ENDPOINT` | Ingestion endpoint (required to upload) |
|
|
80
|
+
| `FLAKEMETRY_TOKEN` | Project ingest token (required to upload) |
|
|
81
|
+
| `FLAKEMETRY_TRANSPORT` | `otlp` (default) or `json` |
|
|
82
|
+
| `FLAKEMETRY_COMPRESSION` | `gzip` to compress the OTLP export |
|
|
83
|
+
| `FLAKEMETRY_BUFFER_DIR` | Buffer runs here when delivery fails; replayed on the next run |
|
|
84
|
+
| `FLAKEMETRY_SAMPLE_RATE` | Fraction (0–1) of *passing* runs to upload; runs with a failure or flake always upload |
|
|
85
|
+
| `FLAKEMETRY_OUTPUT_FILE` | Also write each worker's batch to a file, with the worker id in its name |
|
|
86
|
+
| `FLAKEMETRY_VARIANT` | A variant for the whole run, in front of the capability's |
|
|
87
|
+
|
|
88
|
+
All but the variant can be passed as reporter options instead:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
reporters: [['@flakemetry/wdio-reporter', { outputFile: 'flakemetry-results.json' }]]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT © Andrii Kohut
|