@wopee-io/wopee.pw 4.22.1 → 4.24.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.
@@ -5,7 +5,7 @@ inputs:
5
5
  nodejs-version:
6
6
  description: 'Node.js version.'
7
7
  required: false
8
- default: '21'
8
+ default: '22'
9
9
  npm-token:
10
10
  description: 'Token for @autonomous-testing:=https://npm.pkg.github.com.'
11
11
  required: true
@@ -15,7 +15,7 @@ runs:
15
15
 
16
16
  steps:
17
17
  - name: Setup node
18
- uses: actions/setup-node@v4
18
+ uses: actions/setup-node@v6
19
19
  with:
20
20
  node-version: ${{inputs.nodejs-version}}
21
21
 
@@ -18,7 +18,7 @@ jobs:
18
18
 
19
19
  steps:
20
20
  - name: Check-out
21
- uses: actions/checkout@v4
21
+ uses: actions/checkout@v6
22
22
  with:
23
23
  fetch-depth: 1
24
24
 
@@ -34,7 +34,7 @@ jobs:
34
34
 
35
35
  steps:
36
36
  - name: Check-out
37
- uses: actions/checkout@v4
37
+ uses: actions/checkout@v6
38
38
  with:
39
39
  fetch-depth: 0
40
40
 
@@ -68,7 +68,7 @@ jobs:
68
68
 
69
69
  steps:
70
70
  - name: Check-out
71
- uses: actions/checkout@v4
71
+ uses: actions/checkout@v6
72
72
  with:
73
73
  fetch-depth: 1
74
74
 
@@ -87,7 +87,7 @@ jobs:
87
87
 
88
88
  steps:
89
89
  - name: Check-out
90
- uses: actions/checkout@v4
90
+ uses: actions/checkout@v6
91
91
  with:
92
92
  fetch-depth: 1
93
93
 
@@ -105,7 +105,7 @@ jobs:
105
105
 
106
106
  steps:
107
107
  - name: Check-out
108
- uses: actions/checkout@v4
108
+ uses: actions/checkout@v6
109
109
  with:
110
110
  fetch-depth: 1
111
111
 
@@ -138,7 +138,7 @@ jobs:
138
138
 
139
139
  steps:
140
140
  - name: Check-out
141
- uses: actions/checkout@v4
141
+ uses: actions/checkout@v6
142
142
  with:
143
143
  fetch-depth: 0
144
144
 
package/README.md CHANGED
@@ -1,15 +1,44 @@
1
- <div align="center">
1
+ # Wopee.io Visual Testing for Playwright
2
2
 
3
- # Simplify your Visual Testing
3
+ Catch visual regressions in your [Playwright](https://playwright.dev/) tests with AI-powered autonomous test maintenance by [Wopee.io](https://wopee.io).
4
4
 
5
- Set up in minutes, accurate results instantly.
6
- [![cmd.Wopee.io](https://wopee.io/img/landing/tests-page-new.png)](https://cmd.wopee.io)
5
+ [![npm version](https://img.shields.io/npm/v/@wopee-io/wopee.pw)](https://www.npmjs.com/package/@wopee-io/wopee.pw)
6
+ [![license](https://img.shields.io/npm/l/@wopee-io/wopee.pw)](https://www.npmjs.com/package/@wopee-io/wopee.pw)
7
7
 
8
- </div>
9
- <br/>
8
+ ## Installation
10
9
 
11
- ## [Wopee.io](https://wopee.io) Integration for [Playwright](https://playwright.dev/)
10
+ ```bash
11
+ npm install @wopee-io/wopee.pw
12
+ ```
12
13
 
13
- ### Resources
14
+ ## Quick Start
14
15
 
15
- - [Quick start](https://docs.wopee.io/playwright-visual-testing/)
16
+ ```typescript
17
+ import { test } from '@playwright/test';
18
+ import { Wopee } from '@wopee-io/wopee.pw';
19
+
20
+ const wopee = new Wopee();
21
+
22
+ test.beforeAll(async () => {
23
+ await wopee.startSuite('My Suite');
24
+ });
25
+
26
+ test('visual check', async ({ page }) => {
27
+ await page.goto('https://example.com');
28
+ await wopee.trackFullPage({ page, stepName: 'Homepage' });
29
+ });
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - **Visual regression testing** — pixel-level and AI-powered comparison
35
+ - **Autonomous test maintenance** — AI automatically updates baselines when intended changes are detected
36
+ - **Playwright integration** — works with your existing Playwright test suite
37
+ - **Full page and element screenshots** — flexible capture options
38
+ - **CI/CD ready** — integrates into any pipeline
39
+
40
+ ## Links
41
+
42
+ - [Documentation](https://docs.wopee.io/playwright-visual-testing/) — setup guides and API reference
43
+ - [Wopee.io Platform](https://cmd.wopee.io) — manage baselines, review results
44
+ - [Wopee.io Website](https://wopee.io) — learn more about visual testing
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logVersionMetadata = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const logVersionMetadata = () => {
6
- let version = "4.22.1"
7
- let hash = "a816642e2a4c2816a4f1c7d1f69221474221eedb"
6
+ let version = "4.24.0"
7
+ let hash = "de4b6222b53dd923cf8f50c12731a5cba8d98667"
8
8
  if (version === '__LOCAL__') {
9
9
  version = process.env.npm_package_version || '__LOCAL__';
10
10
  }
@@ -4,26 +4,36 @@ declare const ExtendIntegrationScenarioPayloadSchema: z.ZodObject<{
4
4
  projectUuid: z.ZodString;
5
5
  scenarioUuid: z.ZodString;
6
6
  pwSteps: z.ZodString;
7
+ githubRunId: z.ZodOptional<z.ZodString>;
8
+ githubRunAttempt: z.ZodOptional<z.ZodNumber>;
7
9
  }, "strip", z.ZodTypeAny, {
8
10
  projectUuid?: string;
9
11
  scenarioUuid?: string;
10
12
  pwSteps?: string;
13
+ githubRunId?: string;
14
+ githubRunAttempt?: number;
11
15
  }, {
12
16
  projectUuid?: string;
13
17
  scenarioUuid?: string;
14
18
  pwSteps?: string;
19
+ githubRunId?: string;
20
+ githubRunAttempt?: number;
15
21
  }>;
16
22
  }, "strip", z.ZodTypeAny, {
17
23
  input?: {
18
24
  projectUuid?: string;
19
25
  scenarioUuid?: string;
20
26
  pwSteps?: string;
27
+ githubRunId?: string;
28
+ githubRunAttempt?: number;
21
29
  };
22
30
  }, {
23
31
  input?: {
24
32
  projectUuid?: string;
25
33
  scenarioUuid?: string;
26
34
  pwSteps?: string;
35
+ githubRunId?: string;
36
+ githubRunAttempt?: number;
27
37
  };
28
38
  }>;
29
39
  type ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;
@@ -11,6 +11,8 @@ const ExtendIntegrationScenarioPayloadSchema = zod_1.z.object({
11
11
  required_error: 'Scenario UUID is required, please propagate "testInfo" as second argument in "test.beforeEach" hook and pass it to "wopee.startScenario("scenarioTitle", testInfo)" method as second argument if you want to use features of Wopee reporter',
12
12
  }),
13
13
  pwSteps: zod_1.z.string(),
14
+ githubRunId: zod_1.z.string().optional(),
15
+ githubRunAttempt: zod_1.z.number().optional(),
14
16
  }),
15
17
  });
16
18
  exports.ExtendIntegrationScenarioPayloadSchema = ExtendIntegrationScenarioPayloadSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"wopeeReporter.interface.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/types/wopeeReporter.interface.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,sCAAsC,GAAG,OAAC,CAAC,MAAM,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,cAAc,EAAE,0BAA0B;SAC3C,CAAC;QACF,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACrB,cAAc,EACZ,6OAA6O;SAChP,CAAC;QACF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;KACpB,CAAC;CACH,CAAC,CAAC;AAIM,wFAAsC","sourcesContent":["import { z } from 'zod';\n\nconst ExtendIntegrationScenarioPayloadSchema = z.object({\n input: z.object({\n projectUuid: z.string({\n required_error: 'Project UUID is required',\n }),\n scenarioUuid: z.string({\n required_error:\n 'Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n }),\n pwSteps: z.string(),\n }),\n});\n\ntype ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;\n\nexport { ExtendIntegrationScenarioPayloadSchema, ExtendIntegrationScenarioPayload };\n"]}
1
+ {"version":3,"file":"wopeeReporter.interface.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/types/wopeeReporter.interface.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,sCAAsC,GAAG,OAAC,CAAC,MAAM,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,cAAc,EAAE,0BAA0B;SAC3C,CAAC;QACF,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACrB,cAAc,EACZ,6OAA6O;SAChP,CAAC;QACF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;QAGnB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACxC,CAAC;CACH,CAAC,CAAC;AAIM,wFAAsC","sourcesContent":["import { z } from 'zod';\n\nconst ExtendIntegrationScenarioPayloadSchema = z.object({\n input: z.object({\n projectUuid: z.string({\n required_error: 'Project UUID is required',\n }),\n scenarioUuid: z.string({\n required_error:\n 'Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n }),\n pwSteps: z.string(),\n // Set automatically inside GitHub Actions; lets the backend link this\n // execution to its workflow run so the raw Actions log can be fetched later.\n githubRunId: z.string().optional(),\n githubRunAttempt: z.number().optional(),\n }),\n});\n\ntype ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;\n\nexport { ExtendIntegrationScenarioPayloadSchema, ExtendIntegrationScenarioPayload };\n"]}
@@ -86,11 +86,11 @@ class WopeeReporter {
86
86
  extendIntegrationScenario(input: $input)
87
87
  }`;
88
88
  const extendIntegrationScenarioPayload = {
89
- input: {
90
- projectUuid: WOPEE_PROJECT_UUID,
91
- scenarioUuid: wopeeScenarioUuid,
92
- pwSteps: JSON.stringify(steps, helpers_1.replacer),
93
- },
89
+ input: Object.assign(Object.assign({ projectUuid: WOPEE_PROJECT_UUID, scenarioUuid: wopeeScenarioUuid, pwSteps: JSON.stringify(steps, helpers_1.replacer) }, (process.env.GITHUB_RUN_ID && {
90
+ githubRunId: process.env.GITHUB_RUN_ID,
91
+ })), (process.env.GITHUB_RUN_ATTEMPT && {
92
+ githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),
93
+ })),
94
94
  };
95
95
  const variables = wopeeReporter_interface_js_1.ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);
96
96
  const uploadPromise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DAA6D;AAC7D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAGxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,SAAS,CAAC,IAAc,EAAE,MAAkB;;QAC1C,MAAM,SAAS,GAAG,IAAA,2BAAiB,GAAE,CAAC;QAEtC,MAAM,iBAAiB,GAAG,MAAA,MAAA,MAAM,CAAC,WAAW;aACzC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,qBAAqB,CAAC,0CAC7C,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE5B,MAAM,UAAU,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE1E,MAAM,YAAY,GAAG,CAAC,IAAS,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AAC,CAAC;YAC3G,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAEK,MAAM;;YACV,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,WAAW,CAAC,MAAM,4BAA4B,CAAC,CAAC;gBAC9E,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACpC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBACzD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;gBACxD,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAlID,sCAkIC","sourcesContent":["import { generateTestRunId, parseError, parseNestedSteps, replacer } from './helpers';\nimport { buildAxiosConfig } from './helpers/axios-config.js';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\nimport fs from 'node:fs';\n\nconst { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n\n constructor() {\n this.uploadQueue = [];\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeScenarioUuid = result.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const failedStep = [...result.steps].reverse().find((step) => step.error);\n\n const createStepId = (step: any) => `${step.title}-${step.category}-${step.startTime}`;\n const failedStepId = failedStep ? createStepId(failedStep) : null;\n\n let screenshotBase64: string | null = null;\n let videoBase64: string | null = null;\n\n for (const attachment of result.attachments) {\n if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const imageBuffer = fs.readFileSync(filePath);\n screenshotBase64 = imageBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading screenshot:', error);\n }\n }\n }\n\n if (\n attachment.name === 'video' &&\n (attachment.contentType === 'video/webm' ||\n attachment.contentType === 'video/mp4' ||\n attachment.contentType === 'video/avi')\n ) {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const videoBuffer = fs.readFileSync(filePath);\n videoBase64 = videoBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading video:', error);\n }\n }\n }\n }\n\n if (!wopeeScenarioUuid) {\n return console.error(\n '[WOPEE_REPORTER_ERROR]: Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n );\n }\n\n const steps = result.steps.map((step, index) => ({\n testRunId,\n number: index + 1,\n testTitle: test.title,\n title: step.title,\n status: step.error ? 'failed' : 'passed',\n error: step.error ? parseError(step.error) : step.error,\n category: step.category,\n location: step.location,\n duration: step.duration,\n startTime: step.startTime,\n steps: parseNestedSteps(step.steps),\n screenshotBase64: createStepId(step) === failedStepId ? screenshotBase64 : null,\n videoBase64: createStepId(step) === failedStepId ? videoBase64 : null,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n const uploadPromise = new Promise(async (resolve, reject) => {\n try {\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n const headers = {\n api_key: WOPEE_API_KEY,\n };\n const config = buildAxiosConfig(apiUrl, headers);\n const response = await axios.post(apiUrl, { query, variables }, config);\n resolve(response);\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n const errorMessage = error.message;\n console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);\n reject(new Error(`API request failed with status code: ${status}.`));\n }\n reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error?.message}`));\n }\n });\n\n this.uploadQueue.push(uploadPromise);\n }\n\n async onExit(): Promise<void> {\n if (this.uploadQueue.length > 0) {\n console.log(`Uploading ${this.uploadQueue.length} remaining test results...`);\n try {\n await Promise.all(this.uploadQueue);\n console.log('Successfully uploaded all test results.');\n } catch (error) {\n console.error('Error uploading test results:', error);\n } finally {\n this.uploadQueue = [];\n }\n }\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DAA6D;AAC7D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAGxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,SAAS,CAAC,IAAc,EAAE,MAAkB;;QAC1C,MAAM,SAAS,GAAG,IAAA,2BAAiB,GAAE,CAAC;QAEtC,MAAM,iBAAiB,GAAG,MAAA,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ACxB,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxID,sCAwIC","sourcesContent":["import { generateTestRunId, parseError, parseNestedSteps, replacer } from './helpers';\nimport { buildAxiosConfig } from './helpers/axios-config.js';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\nimport fs from 'node:fs';\n\nconst { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n\n constructor() {\n this.uploadQueue = [];\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeScenarioUuid = result.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const failedStep = [...result.steps].reverse().find((step) => step.error);\n\n const createStepId = (step: any) => `${step.title}-${step.category}-${step.startTime}`;\n const failedStepId = failedStep ? createStepId(failedStep) : null;\n\n let screenshotBase64: string | null = null;\n let videoBase64: string | null = null;\n\n for (const attachment of result.attachments) {\n if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const imageBuffer = fs.readFileSync(filePath);\n screenshotBase64 = imageBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading screenshot:', error);\n }\n }\n }\n\n if (\n attachment.name === 'video' &&\n (attachment.contentType === 'video/webm' ||\n attachment.contentType === 'video/mp4' ||\n attachment.contentType === 'video/avi')\n ) {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const videoBuffer = fs.readFileSync(filePath);\n videoBase64 = videoBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading video:', error);\n }\n }\n }\n }\n\n if (!wopeeScenarioUuid) {\n return console.error(\n '[WOPEE_REPORTER_ERROR]: Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n );\n }\n\n const steps = result.steps.map((step, index) => ({\n testRunId,\n number: index + 1,\n testTitle: test.title,\n title: step.title,\n status: step.error ? 'failed' : 'passed',\n error: step.error ? parseError(step.error) : step.error,\n category: step.category,\n location: step.location,\n duration: step.duration,\n startTime: step.startTime,\n steps: parseNestedSteps(step.steps),\n screenshotBase64: createStepId(step) === failedStepId ? screenshotBase64 : null,\n videoBase64: createStepId(step) === failedStepId ? videoBase64 : null,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n ...(process.env.GITHUB_RUN_ID && {\n githubRunId: process.env.GITHUB_RUN_ID,\n }),\n ...(process.env.GITHUB_RUN_ATTEMPT && {\n githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),\n }),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n const uploadPromise = new Promise(async (resolve, reject) => {\n try {\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n const headers = {\n api_key: WOPEE_API_KEY,\n };\n const config = buildAxiosConfig(apiUrl, headers);\n const response = await axios.post(apiUrl, { query, variables }, config);\n resolve(response);\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n const errorMessage = error.message;\n console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);\n reject(new Error(`API request failed with status code: ${status}.`));\n }\n reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error?.message}`));\n }\n });\n\n this.uploadQueue.push(uploadPromise);\n }\n\n async onExit(): Promise<void> {\n if (this.uploadQueue.length > 0) {\n console.log(`Uploading ${this.uploadQueue.length} remaining test results...`);\n try {\n await Promise.all(this.uploadQueue);\n console.log('Successfully uploaded all test results.');\n } catch (error) {\n console.error('Error uploading test results:', error);\n } finally {\n this.uploadQueue = [];\n }\n }\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "@wopee-io/wopee.pw",
3
- "version": "4.22.1",
4
- "description": "Wopee's Playwright integration.",
3
+ "version": "4.24.0",
4
+ "description": "Playwright visual testing plugin by Wopee.io — catch visual regressions with AI-powered autonomous test maintenance",
5
5
  "keywords": [
6
- "visual testing",
7
6
  "playwright",
8
- "wopee"
7
+ "visual testing",
8
+ "visual regression",
9
+ "screenshot testing",
10
+ "ui testing",
11
+ "test automation",
12
+ "wopee",
13
+ "wopee.io",
14
+ "playwright plugin",
15
+ "visual comparison",
16
+ "autonomous testing",
17
+ "ai testing"
9
18
  ],
10
19
  "scripts": {
11
20
  "build:win": "rm -rf ./build/ && npx tsc && node utils/addVersionToBuild.mjs"
@@ -16,7 +25,7 @@
16
25
  },
17
26
  "author": "Ondrej Winter <ondrej.winter@gmail.com>",
18
27
  "license": "PROPRIETARY",
19
- "homepage": "https://wopee.io",
28
+ "homepage": "https://docs.wopee.io/playwright-visual-testing/",
20
29
  "publishConfig": {
21
30
  "access": "public",
22
31
  "registry": "https://registry.npmjs.org",