@flakiness/sdk 0.152.0 → 0.153.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 +4 -3
- package/lib/browser.js +21 -2
- package/lib/index.js +22 -2
- package/package.json +4 -3
- package/types/src/index.d.ts +1 -1
- package/types/src/index.d.ts.map +1 -1
- package/types/src/reportUtils.d.ts +1 -0
- package/types/src/reportUtils.d.ts.map +1 -1
- package/types/src/reportUtilsBrowser.d.ts +1 -0
- package/types/src/reportUtilsBrowser.d.ts.map +1 -1
- package/types/src/validateReport.d.ts +9 -0
- package/types/src/validateReport.d.ts.map +1 -0
package/README.md
CHANGED
|
@@ -40,8 +40,8 @@ const report: FlakinessReport.Report = {
|
|
|
40
40
|
location: { file: 'test.spec.ts', line: 10, column: 1 },
|
|
41
41
|
attempts: [{
|
|
42
42
|
environmentIdx: 0,
|
|
43
|
+
status: 'passed',
|
|
43
44
|
expectedStatus: 'passed',
|
|
44
|
-
actualStatus: 'passed',
|
|
45
45
|
duration: 100 as FlakinessReport.DurationMS,
|
|
46
46
|
}],
|
|
47
47
|
}],
|
|
@@ -87,11 +87,12 @@ Use this entry point when you need to process or manipulate reports in browser-b
|
|
|
87
87
|
- **`ReportUtils`** - Namespace with utilities for report creation and manipulation:
|
|
88
88
|
- `createEnvironment()` - Create environment objects with system information
|
|
89
89
|
- `normalizeReport()` - Deduplicate environments, suites, and tests
|
|
90
|
-
- `
|
|
90
|
+
- `collectSources()` - Extract source code snippets for locations in the report
|
|
91
91
|
- `stripAnsi()` - Remove ANSI escape codes from strings
|
|
92
92
|
- `visitTests()` - Recursively visit all tests in a report
|
|
93
93
|
- `createFileAttachment()` / `createDataAttachment()` - Create report attachments
|
|
94
|
-
- **`
|
|
94
|
+
- **`CPUUtilization`** - Track CPU utilization over time via periodic sampling
|
|
95
|
+
- **`RAMUtilization`** - Track RAM utilization over time via periodic sampling
|
|
95
96
|
|
|
96
97
|
### Working with Reports
|
|
97
98
|
- **`showReport()`** - Start a local server and open the report in your browser
|
package/lib/browser.js
CHANGED
|
@@ -5,13 +5,14 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/browser.ts
|
|
8
|
-
import { FlakinessReport } from "@flakiness/flakiness-report";
|
|
8
|
+
import { FlakinessReport as FlakinessReport2 } from "@flakiness/flakiness-report";
|
|
9
9
|
|
|
10
10
|
// src/reportUtilsBrowser.ts
|
|
11
11
|
var reportUtilsBrowser_exports = {};
|
|
12
12
|
__export(reportUtilsBrowser_exports, {
|
|
13
13
|
normalizeReport: () => normalizeReport,
|
|
14
14
|
stripAnsi: () => stripAnsi,
|
|
15
|
+
validateReport: () => validateReport,
|
|
15
16
|
visitTests: () => visitTests
|
|
16
17
|
});
|
|
17
18
|
|
|
@@ -173,6 +174,24 @@ function computeTestId(test, suiteId) {
|
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
|
|
177
|
+
// src/validateReport.ts
|
|
178
|
+
import { Schema } from "@flakiness/flakiness-report";
|
|
179
|
+
import z from "zod";
|
|
180
|
+
function validateReport(report) {
|
|
181
|
+
const validation = Schema.Report.safeParse(report);
|
|
182
|
+
if (!validation.success) {
|
|
183
|
+
const MAX_ISSUES = 5;
|
|
184
|
+
const allIssues = validation.error.issues;
|
|
185
|
+
const shownIssues = allIssues.slice(0, MAX_ISSUES);
|
|
186
|
+
const remaining = allIssues.length - shownIssues.length;
|
|
187
|
+
const base = [z.prettifyError(new z.ZodError(shownIssues))];
|
|
188
|
+
if (remaining > 0)
|
|
189
|
+
base.push(`... and ${remaining} more issue${remaining === 1 ? "" : "s"} ...`);
|
|
190
|
+
return base.join("\n");
|
|
191
|
+
}
|
|
192
|
+
return void 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
176
195
|
// src/stripAnsi.ts
|
|
177
196
|
var ansiRegex = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", "g");
|
|
178
197
|
function stripAnsi(str) {
|
|
@@ -195,7 +214,7 @@ function visitTests(report, testVisitor) {
|
|
|
195
214
|
visitSuite(suite, []);
|
|
196
215
|
}
|
|
197
216
|
export {
|
|
198
|
-
FlakinessReport,
|
|
217
|
+
FlakinessReport2 as FlakinessReport,
|
|
199
218
|
reportUtilsBrowser_exports as ReportUtils
|
|
200
219
|
};
|
|
201
220
|
//# sourceMappingURL=browser.js.map
|
package/lib/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
|
-
import { FlakinessReport } from "@flakiness/flakiness-report";
|
|
8
|
+
import { FlakinessReport as FlakinessReport2, Schema as Schema2 } from "@flakiness/flakiness-report";
|
|
9
9
|
|
|
10
10
|
// src/ciUtils.ts
|
|
11
11
|
var CIUtils;
|
|
@@ -473,6 +473,7 @@ __export(reportUtils_exports, {
|
|
|
473
473
|
createFileAttachment: () => createFileAttachment,
|
|
474
474
|
normalizeReport: () => normalizeReport,
|
|
475
475
|
stripAnsi: () => stripAnsi,
|
|
476
|
+
validateReport: () => validateReport,
|
|
476
477
|
visitTests: () => visitTests
|
|
477
478
|
});
|
|
478
479
|
|
|
@@ -777,6 +778,24 @@ function computeTestId(test, suiteId) {
|
|
|
777
778
|
});
|
|
778
779
|
}
|
|
779
780
|
|
|
781
|
+
// src/validateReport.ts
|
|
782
|
+
import { Schema } from "@flakiness/flakiness-report";
|
|
783
|
+
import z from "zod";
|
|
784
|
+
function validateReport(report) {
|
|
785
|
+
const validation = Schema.Report.safeParse(report);
|
|
786
|
+
if (!validation.success) {
|
|
787
|
+
const MAX_ISSUES = 5;
|
|
788
|
+
const allIssues = validation.error.issues;
|
|
789
|
+
const shownIssues = allIssues.slice(0, MAX_ISSUES);
|
|
790
|
+
const remaining = allIssues.length - shownIssues.length;
|
|
791
|
+
const base = [z.prettifyError(new z.ZodError(shownIssues))];
|
|
792
|
+
if (remaining > 0)
|
|
793
|
+
base.push(`... and ${remaining} more issue${remaining === 1 ? "" : "s"} ...`);
|
|
794
|
+
return base.join("\n");
|
|
795
|
+
}
|
|
796
|
+
return void 0;
|
|
797
|
+
}
|
|
798
|
+
|
|
780
799
|
// src/stripAnsi.ts
|
|
781
800
|
var ansiRegex = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", "g");
|
|
782
801
|
function stripAnsi(str) {
|
|
@@ -1311,10 +1330,11 @@ export {
|
|
|
1311
1330
|
CIUtils,
|
|
1312
1331
|
CPUUtilization,
|
|
1313
1332
|
FlakinessProjectConfig,
|
|
1314
|
-
FlakinessReport,
|
|
1333
|
+
FlakinessReport2 as FlakinessReport,
|
|
1315
1334
|
GitWorktree,
|
|
1316
1335
|
RAMUtilization,
|
|
1317
1336
|
reportUtils_exports as ReportUtils,
|
|
1337
|
+
Schema2 as Schema,
|
|
1318
1338
|
showReport,
|
|
1319
1339
|
uploadReport,
|
|
1320
1340
|
writeReport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.153.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,10 +37,11 @@
|
|
|
37
37
|
"typescript": "^5.6.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@flakiness/flakiness-report": "^0.
|
|
40
|
+
"@flakiness/flakiness-report": "^0.20.0",
|
|
41
41
|
"chalk": "^5.6.2",
|
|
42
42
|
"debug": "^4.4.3",
|
|
43
43
|
"open": "^10.2.0",
|
|
44
|
-
"stable-hash": "^0.0.6"
|
|
44
|
+
"stable-hash": "^0.0.6",
|
|
45
|
+
"zod": "^4.3.5"
|
|
45
46
|
}
|
|
46
47
|
}
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FlakinessReport } from '@flakiness/flakiness-report';
|
|
1
|
+
export { FlakinessReport, Schema } from '@flakiness/flakiness-report';
|
|
2
2
|
export { CIUtils } from './ciUtils.js';
|
|
3
3
|
export { CPUUtilization } from './cpuUtilization.js';
|
|
4
4
|
export { GitWorktree } from './gitWorktree.js';
|
package/types/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { collectSources } from './collectSources.js';
|
|
2
2
|
export { createEnvironment } from './createEnvironment.js';
|
|
3
3
|
export { normalizeReport } from './normalizeReport.js';
|
|
4
|
+
export { validateReport } from './validateReport.js';
|
|
4
5
|
export { stripAnsi } from './stripAnsi.js';
|
|
5
6
|
export { createDataAttachment, createFileAttachment } from './uploadReport.js';
|
|
6
7
|
export type { Attachment, DataAttachment, FileAttachment } from './uploadReport.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportUtils.d.ts","sourceRoot":"","sources":["../../src/reportUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,UAAU,EAAE,cAAc,EAC1B,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"reportUtils.d.ts","sourceRoot":"","sources":["../../src/reportUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,UAAU,EAAE,cAAc,EAC1B,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportUtilsBrowser.d.ts","sourceRoot":"","sources":["../../src/reportUtilsBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"reportUtilsBrowser.d.ts","sourceRoot":"","sources":["../../src/reportUtilsBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FlakinessReport } from '@flakiness/flakiness-report';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a report object against the Flakiness Report schema.
|
|
4
|
+
*
|
|
5
|
+
* @param report - The report object to validate
|
|
6
|
+
* @returns A formatted error string if validation fails, or `undefined` if the report is valid
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateReport(report: FlakinessReport.Report): string | undefined;
|
|
9
|
+
//# sourceMappingURL=validateReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateReport.d.ts","sourceRoot":"","sources":["../../src/validateReport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,6BAA6B,CAAC;AAGtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,GAAG,MAAM,GAAC,SAAS,CAe/E"}
|