@testrelic/playwright-analytics 2.6.0-next.38 → 2.6.0-next.42

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.
@@ -0,0 +1,140 @@
1
+ import { ReporterConfig } from '@testrelic/core';
2
+
3
+ /**
4
+ * TestRelicReporter — Playwright custom reporter
5
+ *
6
+ * Captures test execution data and produces a structured JSON timeline.
7
+ * All hooks are wrapped in try/catch (FR-026): never crashes the test run.
8
+ */
9
+
10
+ interface PwFullConfig {
11
+ rootDir: string;
12
+ [key: string]: unknown;
13
+ }
14
+ interface PwSuite {
15
+ allTests(): PwTestCase[];
16
+ }
17
+ interface PwProjectUse {
18
+ browserName?: string;
19
+ channel?: string;
20
+ isMobile?: boolean;
21
+ [key: string]: unknown;
22
+ }
23
+ interface PwFullProject {
24
+ use: PwProjectUse;
25
+ [key: string]: unknown;
26
+ }
27
+ interface PwSuiteNode {
28
+ project?(): PwFullProject | undefined;
29
+ parent?: PwSuiteNode;
30
+ }
31
+ interface PwTestCase {
32
+ title: string;
33
+ titlePath(): string[];
34
+ annotations: Array<{
35
+ type: string;
36
+ description?: string;
37
+ }>;
38
+ tags?: string[];
39
+ location: {
40
+ file: string;
41
+ line: number;
42
+ column: number;
43
+ };
44
+ results: PwTestResult[];
45
+ outcome(): 'expected' | 'unexpected' | 'skipped' | 'flaky';
46
+ expectedStatus: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
47
+ id: string;
48
+ parent?: PwSuiteNode;
49
+ }
50
+ interface PwTestResult {
51
+ status: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
52
+ duration: number;
53
+ startTime: Date;
54
+ retry: number;
55
+ errors: PwTestError[];
56
+ attachments: Array<{
57
+ name: string;
58
+ contentType: string;
59
+ path?: string;
60
+ body?: Buffer;
61
+ }>;
62
+ steps?: readonly PwTestStep[];
63
+ }
64
+ interface PwTestStep {
65
+ title: string;
66
+ category: string;
67
+ startTime: Date;
68
+ duration: number;
69
+ error?: {
70
+ message?: string;
71
+ };
72
+ steps: readonly PwTestStep[];
73
+ }
74
+ interface PwTestError {
75
+ message?: string;
76
+ stack?: string;
77
+ location?: {
78
+ file: string;
79
+ line: number;
80
+ column: number;
81
+ };
82
+ snippet?: string;
83
+ }
84
+ interface PwFullResult {
85
+ status: 'passed' | 'failed' | 'timedout' | 'interrupted';
86
+ startTime: Date;
87
+ duration: number;
88
+ }
89
+ declare class TestRelicReporter {
90
+ private config;
91
+ private apiConfig;
92
+ private rootDir;
93
+ private startedAt;
94
+ private testRunId;
95
+ private collectedTests;
96
+ private fixtureDataReceived;
97
+ private testCount;
98
+ private cloudClient;
99
+ private cloudRunId;
100
+ private runTimestamp;
101
+ private pendingArtifactEntries;
102
+ private detectedOs;
103
+ private detectedSource;
104
+ private cloudTestsBuffer;
105
+ private activeReportMode;
106
+ private streamingWriter;
107
+ private testIndex;
108
+ private summaryCounters;
109
+ constructor(options?: Partial<ReporterConfig>);
110
+ onBegin(config: PwFullConfig, _suite: PwSuite): Promise<void>;
111
+ onTestBegin(test: PwTestCase, _result: PwTestResult): void;
112
+ onTestEnd(test: PwTestCase, result: PwTestResult): void;
113
+ onEnd(_result: PwFullResult): Promise<void>;
114
+ /**
115
+ * Collect artifact entries from all collected tests for cloud upload.
116
+ * In streaming mode, uses the separately accumulated pendingArtifactEntries
117
+ * since collectedTests artifacts are nulled after writing to disk.
118
+ */
119
+ private collectArtifactEntries;
120
+ private finalizeStreamingReport;
121
+ /** Build a lightweight TestRunReport from streaming data (for HTML generation and cloud). */
122
+ private buildStreamingReport;
123
+ printsToStdio(): boolean;
124
+ /** Check heap usage and warn or auto-switch to streaming mode. */
125
+ private checkMemoryPressure;
126
+ /** Switch from embedded to streaming mode mid-run. */
127
+ private switchToStreamingMode;
128
+ private buildTimeline;
129
+ private readJsonlFile;
130
+ private toTestResult;
131
+ /**
132
+ * Build a full payload for cloud upload that includes console logs,
133
+ * network requests, navigations, and actions read from JSONL files.
134
+ * Called before streaming writer moves files and before fields are nulled.
135
+ */
136
+ private buildCloudTestPayload;
137
+ private writeReport;
138
+ }
139
+
140
+ export { TestRelicReporter as default };
@@ -0,0 +1,140 @@
1
+ import { ReporterConfig } from '@testrelic/core';
2
+
3
+ /**
4
+ * TestRelicReporter — Playwright custom reporter
5
+ *
6
+ * Captures test execution data and produces a structured JSON timeline.
7
+ * All hooks are wrapped in try/catch (FR-026): never crashes the test run.
8
+ */
9
+
10
+ interface PwFullConfig {
11
+ rootDir: string;
12
+ [key: string]: unknown;
13
+ }
14
+ interface PwSuite {
15
+ allTests(): PwTestCase[];
16
+ }
17
+ interface PwProjectUse {
18
+ browserName?: string;
19
+ channel?: string;
20
+ isMobile?: boolean;
21
+ [key: string]: unknown;
22
+ }
23
+ interface PwFullProject {
24
+ use: PwProjectUse;
25
+ [key: string]: unknown;
26
+ }
27
+ interface PwSuiteNode {
28
+ project?(): PwFullProject | undefined;
29
+ parent?: PwSuiteNode;
30
+ }
31
+ interface PwTestCase {
32
+ title: string;
33
+ titlePath(): string[];
34
+ annotations: Array<{
35
+ type: string;
36
+ description?: string;
37
+ }>;
38
+ tags?: string[];
39
+ location: {
40
+ file: string;
41
+ line: number;
42
+ column: number;
43
+ };
44
+ results: PwTestResult[];
45
+ outcome(): 'expected' | 'unexpected' | 'skipped' | 'flaky';
46
+ expectedStatus: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
47
+ id: string;
48
+ parent?: PwSuiteNode;
49
+ }
50
+ interface PwTestResult {
51
+ status: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
52
+ duration: number;
53
+ startTime: Date;
54
+ retry: number;
55
+ errors: PwTestError[];
56
+ attachments: Array<{
57
+ name: string;
58
+ contentType: string;
59
+ path?: string;
60
+ body?: Buffer;
61
+ }>;
62
+ steps?: readonly PwTestStep[];
63
+ }
64
+ interface PwTestStep {
65
+ title: string;
66
+ category: string;
67
+ startTime: Date;
68
+ duration: number;
69
+ error?: {
70
+ message?: string;
71
+ };
72
+ steps: readonly PwTestStep[];
73
+ }
74
+ interface PwTestError {
75
+ message?: string;
76
+ stack?: string;
77
+ location?: {
78
+ file: string;
79
+ line: number;
80
+ column: number;
81
+ };
82
+ snippet?: string;
83
+ }
84
+ interface PwFullResult {
85
+ status: 'passed' | 'failed' | 'timedout' | 'interrupted';
86
+ startTime: Date;
87
+ duration: number;
88
+ }
89
+ declare class TestRelicReporter {
90
+ private config;
91
+ private apiConfig;
92
+ private rootDir;
93
+ private startedAt;
94
+ private testRunId;
95
+ private collectedTests;
96
+ private fixtureDataReceived;
97
+ private testCount;
98
+ private cloudClient;
99
+ private cloudRunId;
100
+ private runTimestamp;
101
+ private pendingArtifactEntries;
102
+ private detectedOs;
103
+ private detectedSource;
104
+ private cloudTestsBuffer;
105
+ private activeReportMode;
106
+ private streamingWriter;
107
+ private testIndex;
108
+ private summaryCounters;
109
+ constructor(options?: Partial<ReporterConfig>);
110
+ onBegin(config: PwFullConfig, _suite: PwSuite): Promise<void>;
111
+ onTestBegin(test: PwTestCase, _result: PwTestResult): void;
112
+ onTestEnd(test: PwTestCase, result: PwTestResult): void;
113
+ onEnd(_result: PwFullResult): Promise<void>;
114
+ /**
115
+ * Collect artifact entries from all collected tests for cloud upload.
116
+ * In streaming mode, uses the separately accumulated pendingArtifactEntries
117
+ * since collectedTests artifacts are nulled after writing to disk.
118
+ */
119
+ private collectArtifactEntries;
120
+ private finalizeStreamingReport;
121
+ /** Build a lightweight TestRunReport from streaming data (for HTML generation and cloud). */
122
+ private buildStreamingReport;
123
+ printsToStdio(): boolean;
124
+ /** Check heap usage and warn or auto-switch to streaming mode. */
125
+ private checkMemoryPressure;
126
+ /** Switch from embedded to streaming mode mid-run. */
127
+ private switchToStreamingMode;
128
+ private buildTimeline;
129
+ private readJsonlFile;
130
+ private toTestResult;
131
+ /**
132
+ * Build a full payload for cloud upload that includes console logs,
133
+ * network requests, navigations, and actions read from JSONL files.
134
+ * Called before streaming writer moves files and before fields are nulled.
135
+ */
136
+ private buildCloudTestPayload;
137
+ private writeReport;
138
+ }
139
+
140
+ export { TestRelicReporter as default };