@flakiness/playwright 0.150.0 → 0.152.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.
@@ -4,7 +4,8 @@ import {
4
4
  GitWorktree,
5
5
  ReportUtils,
6
6
  showReport,
7
- SystemUtilizationSampler,
7
+ CPUUtilization,
8
+ RAMUtilization,
8
9
  uploadReport,
9
10
  writeReport
10
11
  } from "@flakiness/sdk";
@@ -27,16 +28,25 @@ var FlakinessReporter = class {
27
28
  constructor(_options = {}) {
28
29
  this._options = _options;
29
30
  this._outputFolder = path.join(process.cwd(), this._options.outputFolder ?? process.env.FLAKINESS_OUTPUT_DIR ?? "flakiness-report");
31
+ this._sampleSystem = this._sampleSystem.bind(this);
32
+ this._sampleSystem();
30
33
  }
31
34
  _config;
32
35
  _rootSuite;
33
36
  _results = /* @__PURE__ */ new Map();
34
37
  _unattributedErrors = [];
35
- _systemUtilizationSampler = new SystemUtilizationSampler();
38
+ _cpuUtilization = new CPUUtilization({ precision: 10 });
39
+ _ramUtilization = new RAMUtilization({ precision: 10 });
36
40
  _report;
37
41
  _attachments = [];
38
42
  _outputFolder;
39
43
  _result;
44
+ _telemetryTimer;
45
+ _sampleSystem() {
46
+ this._cpuUtilization.sample();
47
+ this._ramUtilization.sample();
48
+ this._telemetryTimer = setTimeout(this._sampleSystem, 1e3);
49
+ }
40
50
  printsToStdio() {
41
51
  return false;
42
52
  }
@@ -156,7 +166,9 @@ var FlakinessReporter = class {
156
166
  };
157
167
  }
158
168
  async onEnd(result) {
159
- this._systemUtilizationSampler.dispose();
169
+ clearTimeout(this._telemetryTimer);
170
+ this._cpuUtilization.sample();
171
+ this._ramUtilization.sample();
160
172
  if (!this._config || !this._rootSuite)
161
173
  throw new Error("ERROR: failed to resolve config");
162
174
  let commitId;
@@ -212,20 +224,21 @@ var FlakinessReporter = class {
212
224
  for (let envIdx = 0; envIdx < environments.length; ++envIdx)
213
225
  context.project2environmentIdx.set(this._config.projects[envIdx], envIdx);
214
226
  const report = ReportUtils.normalizeReport({
227
+ version: 1,
215
228
  category: "playwright",
216
229
  commitId: worktree.headCommitId(),
217
230
  relatedCommitIds: [],
218
- systemUtilization: this._systemUtilizationSampler.result,
219
231
  configPath,
220
232
  url: CIUtils.runUrl(),
221
233
  environments,
222
234
  suites: await this._toFKSuites(context, this._rootSuite),
223
- opaqueData: this._config,
224
235
  unattributedErrors: this._unattributedErrors.map((e) => this._toFKTestError(context, e)),
225
236
  duration: parseDurationMS(result.duration),
226
237
  startTimestamp: +result.startTime
227
238
  });
228
- ReportUtils.createTestStepSnippetsInplace(worktree, report);
239
+ ReportUtils.collectSources(worktree, report);
240
+ this._cpuUtilization.enrich(report);
241
+ this._ramUtilization.enrich(report);
229
242
  for (const unaccessibleAttachment of context.unaccessibleAttachmentPaths)
230
243
  warn(`cannot access attachment ${unaccessibleAttachment}`);
231
244
  this._report = report;
@@ -274,8 +287,7 @@ function createEnvironments(projects) {
274
287
  delete metadata.gitDiff;
275
288
  result.set(project, ReportUtils.createEnvironment({
276
289
  name,
277
- userSuppliedData: metadata,
278
- opaqueData: { project }
290
+ metadata
279
291
  }));
280
292
  }
281
293
  return result;
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@flakiness/playwright",
3
- "version": "0.150.0",
3
+ "version": "0.152.0",
4
4
  "private": false,
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/flakiness/playwright.git"
8
+ },
5
9
  "exports": {
6
10
  ".": {
7
11
  "types": "./types/src/playwright-test.d.ts",
@@ -10,13 +14,21 @@
10
14
  }
11
15
  },
12
16
  "type": "module",
13
- "description": "",
17
+ "description": "A custom Playwright test reporter that generates Flakiness Reports from your Playwright test runs",
14
18
  "types": "./types/index.d.ts",
15
19
  "scripts": {
16
20
  "minor": "./version.mjs minor",
17
21
  "patch": "./version.mjs patch"
18
22
  },
19
- "keywords": [],
23
+ "keywords": [
24
+ "playwright",
25
+ "test",
26
+ "reporter",
27
+ "flakiness",
28
+ "testing",
29
+ "e2e",
30
+ "test-reporting"
31
+ ],
20
32
  "author": "Degu Labs, Inc",
21
33
  "license": "MIT",
22
34
  "devDependencies": {
@@ -27,7 +39,7 @@
27
39
  "typescript": "^5.9.3"
28
40
  },
29
41
  "dependencies": {
30
- "@flakiness/sdk": "^0.150.2",
42
+ "@flakiness/sdk": "^0.152.0",
31
43
  "chalk": "^5.6.2"
32
44
  }
33
45
  }
@@ -6,11 +6,13 @@ export default class FlakinessReporter implements Reporter {
6
6
  private _rootSuite?;
7
7
  private _results;
8
8
  private _unattributedErrors;
9
- private _systemUtilizationSampler;
9
+ private _cpuUtilization;
10
+ private _ramUtilization;
10
11
  private _report?;
11
12
  private _attachments;
12
13
  private _outputFolder;
13
14
  private _result?;
15
+ private _telemetryTimer?;
14
16
  constructor(_options?: {
15
17
  endpoint?: string;
16
18
  token?: string;
@@ -18,6 +20,7 @@ export default class FlakinessReporter implements Reporter {
18
20
  open?: OpenMode;
19
21
  collectBrowserVersions?: boolean;
20
22
  });
23
+ private _sampleSystem;
21
24
  printsToStdio(): boolean;
22
25
  onBegin(config: FullConfig, suite: Suite): void;
23
26
  onError(error: TestError): void;
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-test.d.ts","sourceRoot":"","sources":["../../src/playwright-test.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,UAAU,EAEV,UAAU,EAEV,QAAQ,EACR,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAEvC,MAAM,2BAA2B,CAAC;AA6BnC,KAAK,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,QAAQ;IAa5C,OAAO,CAAC,QAAQ;IAZ5B,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAwC;IACxD,OAAO,CAAC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