Skip to content

Commit f94db14

Browse files
authored
docs: fix reporter configuration pattern in all documentation (#24)
Playwright reporters must be specified as file paths, not class instances. Updated all documentation and JSDoc to show the correct pattern: 1. Create a reporter file that extends CoreReporter 2. Reference it by path in playwright.config.ts This matches how lytics-playwright actually uses the reporter.
1 parent 361c588 commit f94db14

18 files changed

Lines changed: 698 additions & 352 deletions

File tree

.dev-agent/config.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"version": "1.0",
3+
"repository": {
4+
"path": ".",
5+
"excludePatterns": [
6+
"**/node_modules/**",
7+
"**/dist/**",
8+
"**/.git/**",
9+
"**/coverage/**"
10+
],
11+
"languages": [
12+
"typescript",
13+
"javascript",
14+
"markdown"
15+
]
16+
},
17+
"mcp": {
18+
"adapters": {
19+
"search": {
20+
"enabled": true
21+
},
22+
"refs": {
23+
"enabled": true
24+
},
25+
"map": {
26+
"enabled": true
27+
},
28+
"history": {
29+
"enabled": true
30+
},
31+
"plan": {
32+
"enabled": true
33+
},
34+
"explore": {
35+
"enabled": true
36+
},
37+
"github": {
38+
"enabled": true
39+
},
40+
"status": {
41+
"enabled": true
42+
},
43+
"health": {
44+
"enabled": true
45+
}
46+
}
47+
},
48+
"repositoryPath": "/Users/prosseng/workspace/playwright-core",
49+
"excludePatterns": [
50+
"**/node_modules/**",
51+
"**/dist/**",
52+
"**/.git/**",
53+
"**/coverage/**"
54+
],
55+
"languages": [
56+
"typescript",
57+
"javascript",
58+
"markdown"
59+
],
60+
"embeddingModel": "Xenova/all-MiniLM-L6-v2",
61+
"dimension": 384
62+
}

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,40 @@ npm install @lytics/playwright-journey
3838

3939
### Basic Usage
4040

41+
**Step 1: Create a reporter file**
42+
4143
```typescript
42-
import { test as base } from "@playwright/test";
43-
import { pushSuiteAnnotation, pushTestAnnotations } from "@lytics/playwright-annotations";
44+
// reporter.ts
4445
import { CoreReporter } from "@lytics/playwright-reporter";
4546
import { FilesystemAdapter } from "@lytics/playwright-adapters/filesystem";
4647

47-
// Configure reporter
48-
export default new CoreReporter({
49-
adapters: [
50-
new FilesystemAdapter({ outputDir: './test-results' })
51-
]
52-
});
48+
class CustomReporter extends CoreReporter {
49+
constructor() {
50+
super({
51+
adapters: [new FilesystemAdapter({ outputDir: './test-results' })]
52+
});
53+
}
54+
}
55+
56+
export default CustomReporter;
57+
```
58+
59+
**Step 2: Configure Playwright**
60+
61+
```typescript
62+
// playwright.config.ts
63+
export default {
64+
reporter: [['list'], ['./reporter.ts']]
65+
};
66+
```
67+
68+
**Step 3: Write annotated tests**
69+
70+
```typescript
71+
// tests/my-feature.spec.ts
72+
import { test } from "@playwright/test";
73+
import { pushSuiteAnnotation, pushTestAnnotations } from "@lytics/playwright-annotations";
5374

54-
// Write tests
5575
test.describe("My Feature @smoke", () => {
5676
test.beforeEach(async ({}, testInfo) => {
5777
pushSuiteAnnotation(testInfo, "MY-PRODUCT");

packages/adapters/README.md

Lines changed: 70 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,35 @@ Writes test results to JSON files on the local filesystem. Useful for local deve
2727

2828
**Example:**
2929

30+
Create a reporter file:
31+
3032
```typescript
33+
// reporter.ts
3134
import { CoreReporter } from '@lytics/playwright-reporter';
3235
import { FilesystemAdapter } from '@lytics/playwright-adapters/filesystem';
3336

37+
class CustomReporter extends CoreReporter {
38+
constructor() {
39+
super({
40+
adapters: [
41+
new FilesystemAdapter({
42+
outputDir: './test-results',
43+
pretty: true, // default: true
44+
}),
45+
],
46+
});
47+
}
48+
}
49+
50+
export default CustomReporter;
51+
```
52+
53+
Reference it in your config:
54+
55+
```typescript
56+
// playwright.config.ts
3457
export default {
35-
reporter: [
36-
['list'],
37-
[
38-
new CoreReporter({
39-
adapters: [
40-
new FilesystemAdapter({
41-
outputDir: './test-results',
42-
pretty: true, // default: true
43-
}),
44-
],
45-
}),
46-
],
47-
],
58+
reporter: [['list'], ['./reporter.ts']],
4859
};
4960
```
5061

@@ -88,32 +99,32 @@ Sends test results to Slack channels using `@lytics/playwright-slack`. Automatic
8899
**Example:**
89100

90101
```typescript
102+
// reporter.ts
91103
import { CoreReporter } from '@lytics/playwright-reporter';
92104
import { FilesystemAdapter } from '@lytics/playwright-adapters/filesystem';
93105
import { SlackAdapter } from '@lytics/playwright-adapters/slack';
94106

95-
export default {
96-
reporter: [
97-
['list'],
98-
[
99-
new CoreReporter({
100-
adapters: [
101-
new FilesystemAdapter({ outputDir: './test-results' }),
102-
new SlackAdapter({
103-
webhookUrl: process.env.SLACK_WEBHOOK_URL,
104-
environment: 'Production',
105-
productionOnly: true, // default: true
106-
skipPullRequests: true, // default: true
107-
dashboardUrl: 'https://dashboard.example.com',
108-
ciJobUrl: process.env.CI_JOB_URL,
109-
artifactBaseUrl: process.env.ARTIFACT_BASE_URL,
110-
triggerType: process.env.TRIGGER_TYPE,
111-
}),
112-
],
113-
}),
114-
],
115-
],
116-
};
107+
class CustomReporter extends CoreReporter {
108+
constructor() {
109+
super({
110+
adapters: [
111+
new FilesystemAdapter({ outputDir: './test-results' }),
112+
new SlackAdapter({
113+
webhookUrl: process.env.SLACK_WEBHOOK_URL!,
114+
environment: 'Production',
115+
productionOnly: true, // default: true
116+
skipPullRequests: true, // default: true
117+
dashboardUrl: 'https://dashboard.example.com',
118+
ciJobUrl: process.env.CI_JOB_URL,
119+
artifactBaseUrl: process.env.ARTIFACT_BASE_URL,
120+
triggerType: process.env.TRIGGER_TYPE,
121+
}),
122+
],
123+
});
124+
}
125+
}
126+
127+
export default CustomReporter;
117128
```
118129

119130
**Configuration:**
@@ -165,33 +176,33 @@ Writes test results to Google Cloud Firestore. Supports automatic retry with exp
165176
**Example:**
166177

167178
```typescript
179+
// reporter.ts
168180
import { CoreReporter } from '@lytics/playwright-reporter';
169181
import { FirestoreAdapter } from '@lytics/playwright-adapters/firestore';
170182

171-
export default {
172-
reporter: [
173-
['list'],
174-
[
175-
new CoreReporter({
176-
adapters: [
177-
new FirestoreAdapter({
178-
projectId: 'my-gcp-project',
179-
credentials: process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON,
180-
// Configure your own collection names to match your Firestore schema
181-
collections: {
182-
testRuns: 'your_test_runs_collection',
183-
testCases: 'your_test_cases_collection',
184-
latestTestCases: 'your_latest_test_cases_collection',
185-
},
186-
skipConditions: {
187-
skipPullRequests: true,
188-
},
189-
}),
190-
],
191-
}),
192-
],
193-
],
194-
};
183+
class CustomReporter extends CoreReporter {
184+
constructor() {
185+
super({
186+
adapters: [
187+
new FirestoreAdapter({
188+
projectId: 'my-gcp-project',
189+
credentials: process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON,
190+
// Configure your own collection names to match your Firestore schema
191+
collections: {
192+
testRuns: 'your_test_runs_collection',
193+
testCases: 'your_test_cases_collection',
194+
latestTestCases: 'your_latest_test_cases_collection',
195+
},
196+
skipConditions: {
197+
skipPullRequests: true,
198+
},
199+
}),
200+
],
201+
});
202+
}
203+
}
204+
205+
export default CustomReporter;
195206
```
196207

197208
**Configuration:**

packages/adapters/src/index.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,32 @@
1111
*
1212
* @example
1313
* ```typescript
14+
* // reporter.ts
1415
* import { CoreReporter } from '@lytics/playwright-reporter';
1516
* import { FilesystemAdapter } from '@lytics/playwright-adapters/filesystem';
1617
* import { SlackAdapter } from '@lytics/playwright-adapters/slack';
1718
* import { FirestoreAdapter } from '@lytics/playwright-adapters/firestore';
1819
*
19-
* const reporter = new CoreReporter({
20-
* adapters: [
21-
* new FilesystemAdapter({ outputDir: './test-results' }),
22-
* new SlackAdapter({ webhookUrl: process.env.SLACK_WEBHOOK_URL }),
23-
* new FirestoreAdapter({
24-
* projectId: 'my-gcp-project',
25-
* collections: {
26-
* testRuns: 'test_runs',
27-
* testCases: 'test_cases',
28-
* latestTestCases: 'latest_test_cases'
29-
* }
30-
* })
31-
* ]
32-
* });
20+
* class CustomReporter extends CoreReporter {
21+
* constructor() {
22+
* super({
23+
* adapters: [
24+
* new FilesystemAdapter({ outputDir: './test-results' }),
25+
* new SlackAdapter({ webhookUrl: process.env.SLACK_WEBHOOK_URL! }),
26+
* new FirestoreAdapter({
27+
* projectId: 'my-gcp-project',
28+
* collections: {
29+
* testRuns: 'test_runs',
30+
* testCases: 'test_cases',
31+
* latestTestCases: 'latest_test_cases'
32+
* }
33+
* })
34+
* ]
35+
* });
36+
* }
37+
* }
38+
*
39+
* export default CustomReporter;
3340
* ```
3441
*
3542
* @packageDocumentation

packages/annotations/README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,37 @@ Annotations enable:
301301

302302
### With Reporter
303303

304-
Annotations are consumed by `@lytics/playwright-reporter`:
304+
Annotations are consumed by `@lytics/playwright-reporter`. Create a reporter file:
305305

306306
```typescript
307+
// reporter.ts
307308
import { CoreReporter } from '@lytics/playwright-reporter';
308309
import { FirestoreAdapter } from '@lytics/playwright-adapters/firestore';
309310

310-
export default new CoreReporter({
311-
adapters: [
312-
new FirestoreAdapter({
313-
projectId: 'my-project',
314-
// Adapter uses annotations for querying and grouping
315-
}),
316-
],
317-
});
311+
class CustomReporter extends CoreReporter {
312+
constructor() {
313+
super({
314+
adapters: [
315+
new FirestoreAdapter({
316+
projectId: 'my-project',
317+
collections: { /* ... */ },
318+
// Adapter uses annotations for querying and grouping
319+
}),
320+
],
321+
});
322+
}
323+
}
324+
325+
export default CustomReporter;
326+
```
327+
328+
Reference it in your config:
329+
330+
```typescript
331+
// playwright.config.ts
332+
export default {
333+
reporter: [['list'], ['./reporter.ts']]
334+
};
318335
```
319336

320337
### With Journey Tools

0 commit comments

Comments
 (0)