@wopee-io/wopee.pw 4.26.0 → 4.26.1

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.
@@ -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.26.0"
7
- let hash = "e6db6ed17dd89634c4c1857b8be9c70994ac2186"
6
+ let version = "4.26.1"
7
+ let hash = "fe83ca0dc8ab9364ec77655b8b0575ef4f632c1f"
8
8
  if (version === '__LOCAL__') {
9
9
  version = process.env.npm_package_version || '__LOCAL__';
10
10
  }
@@ -163,6 +163,7 @@ class WopeeReporter {
163
163
  const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';
164
164
  const headers = {
165
165
  api_key: WOPEE_API_KEY,
166
+ 'x-api-key': WOPEE_API_KEY,
166
167
  };
167
168
  return { apiUrl, config: (0, axios_config_js_1.buildAxiosConfig)(apiUrl, headers) };
168
169
  }
@@ -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,MAAa,aAAa;IAKxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAMO,GAAG;QACT,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;QACzE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC;IAC9D,CAAC;IAOO,cAAc;QAC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AAM,CAAC;wBACN,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,eAAe,CAAC,CAAC;oBACtD,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,OAAO,CAAC,KAAK,CAAC,+CAA+C,SAAS,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,CAAC,CAAC;gBAC/F,CAAC;YACH,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAhOD,sCAgOC","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\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n private suiteUuids: Set<string>;\n private configWarned: boolean;\n\n constructor() {\n this.uploadQueue = [];\n this.suiteUuids = new Set();\n this.configWarned = false;\n }\n\n /*\n Read lazily rather than at module load, so a playwright.config.ts that assigns\n process.env.WOPEE_* at runtime is picked up.\n */\n private env() {\n const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n return { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID };\n }\n\n /*\n A reporter must never fail the run, so this warns and skips rather than\n throwing — otherwise an unauthenticated request is queued and its 401 is\n swallowed by onExit, leaving the user with silently missing results.\n */\n private hasCredentials(): boolean {\n const { WOPEE_API_KEY, WOPEE_PROJECT_UUID } = this.env();\n const missing = [\n ...(WOPEE_API_KEY?.trim() ? [] : ['WOPEE_API_KEY']),\n ...(WOPEE_PROJECT_UUID?.trim() ? [] : ['WOPEE_PROJECT_UUID']),\n ];\n\n if (missing.length === 0) {\n return true;\n }\n\n if (!this.configWarned) {\n this.configWarned = true;\n console.error(\n `[WOPEE_REPORTER_ERROR]: Wopee reporter is disabled — ${missing.join(' and ')} ${\n missing.length > 1 ? 'are' : 'is'\n } not set. Get credentials from Project Settings → API Keys at https://cmd.wopee.io and set them in your shell, a .env file, or CI secrets. Test results will not be uploaded.`,\n );\n }\n return false;\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeSuiteUuid = result.attachments.find((a) => a?.name === 'wopee-suite-uuid')?.body?.toString('utf-8');\n if (wopeeSuiteUuid) {\n this.suiteUuids.add(wopeeSuiteUuid);\n }\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 if (!this.hasCredentials()) {\n return;\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: this.env().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, config } = this.apiRequestConfig();\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 return 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 await this.stopSuites();\n }\n\n private apiRequestConfig() {\n const { WOPEE_API_KEY, WOPEE_API_URL } = this.env();\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n const headers = {\n api_key: WOPEE_API_KEY,\n };\n return { apiUrl, config: buildAxiosConfig(apiUrl, headers) };\n }\n\n // Teardown is best-effort: a failed stop must never fail the run — suites are also\n // finished lazily by the API when left IDLE.\n private async stopSuites(): Promise<void> {\n // Without credentials this would fire unauthenticated requests whose 401s\n // contradict the \"results will not be uploaded\" warning already logged.\n if (this.suiteUuids.size > 0 && !this.hasCredentials()) {\n this.suiteUuids.clear();\n return;\n }\n\n const query = `\n mutation StopIntegrationSuite($suiteUuid: ID!) {\n stopIntegrationSuite(suiteUuid: $suiteUuid) { uuid suiteRunningStatus }\n }`;\n\n for (const suiteUuid of this.suiteUuids) {\n try {\n const { apiUrl, config } = this.apiRequestConfig();\n const response = await axios.post(apiUrl, { query, variables: { suiteUuid } }, config);\n const errors = response.data?.errors;\n if (errors?.length) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}:`, errors[0]?.message);\n } else {\n console.log(`Suite(uuid=${suiteUuid}) is stopped.`);\n }\n } catch (error: any) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}: ${error?.message}`);\n }\n }\n this.suiteUuids.clear();\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,MAAa,aAAa;IAKxB;QACE,IAAI,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AM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;oBACvF,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,MAAM,CAAC;oBACrC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE,CAAC;wBACnB,OAAO,CAAC,KAAK,CAAC,+CAA+C,SAAS,GAAG,EAAE,MAAA,MAAM,CAAC,CAAC,CAAC,0CAAE,OAAO,CAAC,CAAC;oBACjG,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,eAAe,CAAC,CAAC;oBACtD,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,OAAO,CAAC,KAAK,CAAC,+CAA+C,SAAS,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,CAAC,CAAC;gBAC/F,CAAC;YACH,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtOD,sCAsOC","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\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n private suiteUuids: Set<string>;\n private configWarned: boolean;\n\n constructor() {\n this.uploadQueue = [];\n this.suiteUuids = new Set();\n this.configWarned = false;\n }\n\n /*\n Read lazily rather than at module load, so a playwright.config.ts that assigns\n process.env.WOPEE_* at runtime is picked up.\n */\n private env() {\n const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n return { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID };\n }\n\n /*\n A reporter must never fail the run, so this warns and skips rather than\n throwing — otherwise an unauthenticated request is queued and its 401 is\n swallowed by onExit, leaving the user with silently missing results.\n */\n private hasCredentials(): boolean {\n const { WOPEE_API_KEY, WOPEE_PROJECT_UUID } = this.env();\n const missing = [\n ...(WOPEE_API_KEY?.trim() ? [] : ['WOPEE_API_KEY']),\n ...(WOPEE_PROJECT_UUID?.trim() ? [] : ['WOPEE_PROJECT_UUID']),\n ];\n\n if (missing.length === 0) {\n return true;\n }\n\n if (!this.configWarned) {\n this.configWarned = true;\n console.error(\n `[WOPEE_REPORTER_ERROR]: Wopee reporter is disabled — ${missing.join(' and ')} ${\n missing.length > 1 ? 'are' : 'is'\n } not set. Get credentials from Project Settings → API Keys at https://cmd.wopee.io and set them in your shell, a .env file, or CI secrets. Test results will not be uploaded.`,\n );\n }\n return false;\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeSuiteUuid = result.attachments.find((a) => a?.name === 'wopee-suite-uuid')?.body?.toString('utf-8');\n if (wopeeSuiteUuid) {\n this.suiteUuids.add(wopeeSuiteUuid);\n }\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 if (!this.hasCredentials()) {\n return;\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: this.env().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, config } = this.apiRequestConfig();\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 return 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 await this.stopSuites();\n }\n\n private apiRequestConfig() {\n const { WOPEE_API_KEY, WOPEE_API_URL } = this.env();\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n // The same key under two names. `api_key` is what the api has always read; corporate\n // gateways in front of tenant apis strip header names with an underscore (nginx\n // `underscores_in_headers off` and the like) — measured 2026-10-01 behind a bank's load\n // balancer, where every call arrived keyless and was refused as if the key were wrong.\n // `x-api-key` is the alias the api reads since v5.216.2; an older api ignores it.\n const headers = {\n api_key: WOPEE_API_KEY,\n 'x-api-key': WOPEE_API_KEY,\n };\n return { apiUrl, config: buildAxiosConfig(apiUrl, headers) };\n }\n\n // Teardown is best-effort: a failed stop must never fail the run — suites are also\n // finished lazily by the API when left IDLE.\n private async stopSuites(): Promise<void> {\n // Without credentials this would fire unauthenticated requests whose 401s\n // contradict the \"results will not be uploaded\" warning already logged.\n if (this.suiteUuids.size > 0 && !this.hasCredentials()) {\n this.suiteUuids.clear();\n return;\n }\n\n const query = `\n mutation StopIntegrationSuite($suiteUuid: ID!) {\n stopIntegrationSuite(suiteUuid: $suiteUuid) { uuid suiteRunningStatus }\n }`;\n\n for (const suiteUuid of this.suiteUuids) {\n try {\n const { apiUrl, config } = this.apiRequestConfig();\n const response = await axios.post(apiUrl, { query, variables: { suiteUuid } }, config);\n const errors = response.data?.errors;\n if (errors?.length) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}:`, errors[0]?.message);\n } else {\n console.log(`Suite(uuid=${suiteUuid}) is stopped.`);\n }\n } catch (error: any) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}: ${error?.message}`);\n }\n }\n this.suiteUuids.clear();\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
@@ -37,7 +37,12 @@ class ApolloAdapter extends core_1.ApiPort {
37
37
  }
38
38
  async _post(query, variables) {
39
39
  const apiUrl = this._config.apiUrl;
40
- const headers = { api_key: this._config.apiKey };
40
+ // The same key under two names. `api_key` is what the api has always read; corporate
41
+ // gateways in front of tenant apis strip header names with an underscore (nginx
42
+ // `underscores_in_headers off` and the like) — measured 2026-10-01 behind a bank's load
43
+ // balancer, where every call arrived keyless and was refused as if the key were wrong.
44
+ // `x-api-key` is the alias the api reads since v5.216.2; an older api ignores it.
45
+ const headers = { api_key: this._config.apiKey, 'x-api-key': this._config.apiKey };
41
46
  const timeoutMs = this._config.requestTimeoutMs;
42
47
  const requestConfig = (0, axios_config_1.buildAxiosConfig)(apiUrl, headers, timeoutMs);
43
48
  const maxRetries = this._config.maxRetries;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hash = exports.version = void 0;
4
- exports.version = "3.10.0"
5
- exports.hash = "01f4d6f865ec807de8d25e5271e0b67b977f90c1"
4
+ exports.version = "3.10.1"
5
+ exports.hash = "f4aa3b2f38308f0704ac8b622ef66a359d7252c0"
6
6
  //# sourceMappingURL=versionMetadata.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonomous-testing/sdk",
3
- "version": "3.10.0",
3
+ "version": "3.10.1",
4
4
  "scripts": {
5
5
  "build:win": "rm -rf ./build/ && npx tsc && node utils/addVersionToBuild.mjs"
6
6
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopee-io/wopee.pw",
3
- "version": "4.26.0",
3
+ "version": "4.26.1",
4
4
  "description": "Playwright visual testing plugin by Wopee.io — catch visual regressions with AI-powered autonomous test maintenance",
5
5
  "keywords": [
6
6
  "playwright",
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@autonomous-testing/sdk": "3.10.0",
49
+ "@autonomous-testing/sdk": "3.10.1",
50
50
  "axios": "^1.20.0",
51
51
  "dotenv": "^16.6.1",
52
52
  "http-proxy-agent": "^7.0.2",