@stablyai/playwright-test 2.1.0 → 2.1.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.
- package/dist/{index-BkZMxEK6.mjs → index-CI2c83oz.mjs} +6775 -9322
- package/dist/index-CI2c83oz.mjs.map +1 -0
- package/dist/{index-DRjTX1iC.cjs → index-Dg_zRYuy.cjs} +6778 -9325
- package/dist/index-Dg_zRYuy.cjs.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d-BjGuH5NO.d.cts.map +1 -1
- package/dist/index.d-BjGuH5NO.d.mts.map +1 -1
- package/dist/index.d-BjGuH5NO.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/reporter.cjs +2 -2
- package/dist/reporter.mjs +2 -2
- package/package.json +3 -3
- package/dist/index-BkZMxEK6.mjs.map +0 -1
- package/dist/index-DRjTX1iC.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var require$$0 = require('path');
|
|
3
|
+
var require$$0$1 = require('path');
|
|
4
4
|
var require$$7 = require('url');
|
|
5
5
|
var test$1 = require('@playwright/test');
|
|
6
6
|
var playwrightBase = require('@stablyai/playwright-base');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-Dg_zRYuy.cjs');
|
|
8
8
|
require('node:buffer');
|
|
9
9
|
require('node:path');
|
|
10
10
|
require('node:child_process');
|
|
@@ -31,7 +31,7 @@ require('buffer');
|
|
|
31
31
|
require('os');
|
|
32
32
|
|
|
33
33
|
function getDirname(importMetaUrl) {
|
|
34
|
-
return require$$0.dirname(require$$7.fileURLToPath(importMetaUrl));
|
|
34
|
+
return require$$0$1.dirname(require$$7.fileURLToPath(importMetaUrl));
|
|
35
35
|
}
|
|
36
36
|
function getFilename(importMetaUrl) {
|
|
37
37
|
return require$$7.fileURLToPath(importMetaUrl);
|
|
@@ -62,7 +62,7 @@ Object.defineProperty(exports, "setApiKey", {
|
|
|
62
62
|
enumerable: true,
|
|
63
63
|
get: function () { return playwrightBase.setApiKey; }
|
|
64
64
|
});
|
|
65
|
-
exports.stablyReporter = index.
|
|
65
|
+
exports.stablyReporter = index.Sa;
|
|
66
66
|
exports.defineConfig = defineConfig;
|
|
67
67
|
exports.expect = expect;
|
|
68
68
|
exports.getDirname = getDirname;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { dirname } from \"path\";\nimport { fileURLToPath } from \"url\";\n\nimport type { BrowserContext } from \"@playwright/test\";\nimport {\n defineConfig as playwrightDefineConfig,\n expect as playwrightExpect,\n test as playwrightTest,\n} from \"@playwright/test\";\nimport \"@stablyai/playwright-base\";\n\nimport type { Agent } from \"@stablyai/playwright-base\";\nimport {\n augmentBrowser,\n augmentBrowserContext,\n augmentPage,\n stablyPlaywrightMatchers,\n} from \"@stablyai/playwright-base\";\n\nimport type { StablyNotificationConfig } from \"@stablyai/playwright-reporter\";\n\nexport { stablyReporter } from \"@stablyai/playwright-reporter\";\nexport type {\n StablyReporterOptions,\n ProjectNotificationConfig,\n NotificationResultPolicy,\n StablyEmailNotificationConfig,\n StablySlackNotificationConfig,\n StablyNotificationConfig,\n} from \"@stablyai/playwright-reporter\";\nexport { Agent, setApiKey } from \"@stablyai/playwright-base\";\nexport type {\n AIModel,\n GetLocatorsByAIOptions,\n GetLocatorsByAIResult,\n ScreenshotPromptOptions,\n} from \"@stablyai/playwright-base\";\n\n/**\n * Get the directory name from an import.meta.url.\n * This is the ESM equivalent of __dirname.\n *\n * @example\n * ```ts\n * import { getDirname } from '@stablyai/playwright-test';\n * const __dirname = getDirname(import.meta.url);\n *\n * // Use in tests for file paths\n * await page.setInputFiles('input', path.join(__dirname, 'fixtures', 'file.pdf'));\n * ```\n */\nexport function getDirname(importMetaUrl: string): string {\n return dirname(fileURLToPath(importMetaUrl));\n}\n\n/**\n * Get the filename from an import.meta.url.\n * This is the ESM equivalent of __filename.\n *\n * @example\n * ```ts\n * import { getFilename } from '@stablyai/playwright-test';\n * const __filename = getFilename(import.meta.url);\n * ```\n */\nexport function getFilename(importMetaUrl: string): string {\n return fileURLToPath(importMetaUrl);\n}\n\nexport const test: typeof playwrightTest = playwrightTest.extend<{\n agent: Agent;\n}>({\n agent: async (\n { context }: { context: BrowserContext },\n use: (agent: Agent) => Promise<void>,\n ) => {\n // Create a default agent from the default context\n const agent = context.newAgent();\n await use(agent);\n },\n browser: async ({ browser }, use) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await use(augmentBrowser(browser as any) as any);\n },\n context: async ({ context }, use) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await use(augmentBrowserContext(context as any) as any);\n },\n page: async ({ page }, use) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await use(augmentPage(page as any) as any);\n },\n});\n\nexport const expect = playwrightExpect.extend(stablyPlaywrightMatchers);\n\nexport * from \"@playwright/test\";\n\nexport type StablyProjectConfig = {\n notifications?: StablyNotificationConfig;\n};\n\n/**\n * Stably-enhanced defineConfig with typed support for stably notification configuration in projects.\n * The `stably` property on projects is available via module augmentation of `@playwright/test`.\n *\n * @example\n * ```ts\n * import { defineConfig, stablyReporter } from \"@stablyai/playwright-test\";\n *\n * export default defineConfig({\n * reporter: [stablyReporter({ apiKey: \"...\" })],\n * projects: [\n * {\n * name: \"smoke\",\n * stably: {\n * notifications: {\n * slack: { channelName: \"#alerts\", notifyOnResult: \"failures-only\" },\n * },\n * },\n * },\n * ],\n * });\n * ```\n */\nexport const defineConfig = playwrightDefineConfig;\n\ndeclare module \"@playwright/test\" {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface LocatorAssertions {\n /**\n * Asserts that the locator satisfies a natural language condition using AI vision.\n *\n * Takes a screenshot of the locator and uses AI to verify whether the specified condition is met.\n *\n * @param condition - A natural language description of what should be true about the locator\n * @param options - Optional screenshot options (e.g., timeout)\n *\n * @example\n * ```typescript\n * await expect(page.locator('.button')).aiAssert('The button is disabled and grayed out');\n * ```\n */\n aiAssert(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n\n /**\n * @deprecated Use `aiAssert` instead. This method will be removed in a future version.\n */\n toMatchScreenshotPrompt(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface PageAssertions {\n /**\n * Asserts that the page satisfies a natural language condition using AI vision.\n *\n * Takes a screenshot of the page and uses AI to verify whether the specified condition is met.\n *\n * @param condition - A natural language description of what should be true about the page\n * @param options - Optional screenshot options (e.g., fullPage, timeout)\n *\n * @example\n * ```typescript\n * await expect(page).aiAssert('The page shows a success message after form submission');\n * ```\n */\n aiAssert(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n\n /**\n * @deprecated Use `aiAssert` instead. This method will be removed in a future version.\n */\n toMatchScreenshotPrompt(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n }\n\n // Add agent fixture to test args\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface PlaywrightTestArgs {\n agent: Agent;\n }\n\n // Add stably config to project configuration\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Project {\n stably?: StablyProjectConfig;\n }\n}\n"],"names":["dirname","fileURLToPath","playwrightTest","augmentBrowser","augmentBrowserContext","augmentPage","playwrightExpect","stablyPlaywrightMatchers","playwrightDefineConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,SAAS,WAAW,aAAA,EAA+B;AACxD,EAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { dirname } from \"path\";\nimport { fileURLToPath } from \"url\";\n\nimport type { BrowserContext } from \"@playwright/test\";\nimport {\n defineConfig as playwrightDefineConfig,\n expect as playwrightExpect,\n test as playwrightTest,\n} from \"@playwright/test\";\nimport \"@stablyai/playwright-base\";\n\nimport type { Agent } from \"@stablyai/playwright-base\";\nimport {\n augmentBrowser,\n augmentBrowserContext,\n augmentPage,\n stablyPlaywrightMatchers,\n} from \"@stablyai/playwright-base\";\n\nimport type { StablyNotificationConfig } from \"@stablyai/playwright-reporter\";\n\nexport { stablyReporter } from \"@stablyai/playwright-reporter\";\nexport type {\n StablyReporterOptions,\n ProjectNotificationConfig,\n NotificationResultPolicy,\n StablyEmailNotificationConfig,\n StablySlackNotificationConfig,\n StablyNotificationConfig,\n} from \"@stablyai/playwright-reporter\";\nexport { Agent, setApiKey } from \"@stablyai/playwright-base\";\nexport type {\n AIModel,\n GetLocatorsByAIOptions,\n GetLocatorsByAIResult,\n ScreenshotPromptOptions,\n} from \"@stablyai/playwright-base\";\n\n/**\n * Get the directory name from an import.meta.url.\n * This is the ESM equivalent of __dirname.\n *\n * @example\n * ```ts\n * import { getDirname } from '@stablyai/playwright-test';\n * const __dirname = getDirname(import.meta.url);\n *\n * // Use in tests for file paths\n * await page.setInputFiles('input', path.join(__dirname, 'fixtures', 'file.pdf'));\n * ```\n */\nexport function getDirname(importMetaUrl: string): string {\n return dirname(fileURLToPath(importMetaUrl));\n}\n\n/**\n * Get the filename from an import.meta.url.\n * This is the ESM equivalent of __filename.\n *\n * @example\n * ```ts\n * import { getFilename } from '@stablyai/playwright-test';\n * const __filename = getFilename(import.meta.url);\n * ```\n */\nexport function getFilename(importMetaUrl: string): string {\n return fileURLToPath(importMetaUrl);\n}\n\nexport const test: typeof playwrightTest = playwrightTest.extend<{\n agent: Agent;\n}>({\n agent: async (\n { context }: { context: BrowserContext },\n use: (agent: Agent) => Promise<void>,\n ) => {\n // Create a default agent from the default context\n const agent = context.newAgent();\n await use(agent);\n },\n browser: async ({ browser }, use) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await use(augmentBrowser(browser as any) as any);\n },\n context: async ({ context }, use) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await use(augmentBrowserContext(context as any) as any);\n },\n page: async ({ page }, use) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await use(augmentPage(page as any) as any);\n },\n});\n\nexport const expect = playwrightExpect.extend(stablyPlaywrightMatchers);\n\nexport * from \"@playwright/test\";\n\nexport type StablyProjectConfig = {\n notifications?: StablyNotificationConfig;\n};\n\n/**\n * Stably-enhanced defineConfig with typed support for stably notification configuration in projects.\n * The `stably` property on projects is available via module augmentation of `@playwright/test`.\n *\n * @example\n * ```ts\n * import { defineConfig, stablyReporter } from \"@stablyai/playwright-test\";\n *\n * export default defineConfig({\n * reporter: [stablyReporter({ apiKey: \"...\" })],\n * projects: [\n * {\n * name: \"smoke\",\n * stably: {\n * notifications: {\n * slack: { channelName: \"#alerts\", notifyOnResult: \"failures-only\" },\n * },\n * },\n * },\n * ],\n * });\n * ```\n */\nexport const defineConfig = playwrightDefineConfig;\n\ndeclare module \"@playwright/test\" {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface LocatorAssertions {\n /**\n * Asserts that the locator satisfies a natural language condition using AI vision.\n *\n * Takes a screenshot of the locator and uses AI to verify whether the specified condition is met.\n *\n * @param condition - A natural language description of what should be true about the locator\n * @param options - Optional screenshot options (e.g., timeout)\n *\n * @example\n * ```typescript\n * await expect(page.locator('.button')).aiAssert('The button is disabled and grayed out');\n * ```\n */\n aiAssert(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n\n /**\n * @deprecated Use `aiAssert` instead. This method will be removed in a future version.\n */\n toMatchScreenshotPrompt(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface PageAssertions {\n /**\n * Asserts that the page satisfies a natural language condition using AI vision.\n *\n * Takes a screenshot of the page and uses AI to verify whether the specified condition is met.\n *\n * @param condition - A natural language description of what should be true about the page\n * @param options - Optional screenshot options (e.g., fullPage, timeout)\n *\n * @example\n * ```typescript\n * await expect(page).aiAssert('The page shows a success message after form submission');\n * ```\n */\n aiAssert(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n\n /**\n * @deprecated Use `aiAssert` instead. This method will be removed in a future version.\n */\n toMatchScreenshotPrompt(\n condition: string,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n ): Promise<void>;\n }\n\n // Add agent fixture to test args\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface PlaywrightTestArgs {\n agent: Agent;\n }\n\n // Add stably config to project configuration\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Project {\n stably?: StablyProjectConfig;\n }\n}\n"],"names":["dirname","fileURLToPath","playwrightTest","augmentBrowser","augmentBrowserContext","augmentPage","playwrightExpect","stablyPlaywrightMatchers","playwrightDefineConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,SAAS,WAAW,aAAA,EAA+B;AACxD,EAAA,OAAOA,oBAAA,CAAQC,wBAAA,CAAc,aAAa,CAAC,CAAA;AAC7C;AAYO,SAAS,YAAY,aAAA,EAA+B;AACzD,EAAA,OAAOA,yBAAc,aAAa,CAAA;AACpC;AAEO,MAAM,IAAA,GAA8BC,YAAe,MAAA,CAEvD;AAAA,EACD,KAAA,EAAO,OACL,EAAE,OAAA,IACF,GAAA,KACG;AAEH,IAAA,MAAM,KAAA,GAAQ,QAAQ,QAAA,EAAS;AAC/B,IAAA,MAAM,IAAI,KAAK,CAAA;AAAA,EACjB,CAAA;AAAA,EACA,OAAA,EAAS,OAAO,EAAE,OAAA,IAAW,GAAA,KAAQ;AAEnC,IAAA,MAAM,GAAA,CAAIC,6BAAA,CAAe,OAAc,CAAQ,CAAA;AAAA,EACjD,CAAA;AAAA,EACA,OAAA,EAAS,OAAO,EAAE,OAAA,IAAW,GAAA,KAAQ;AAEnC,IAAA,MAAM,GAAA,CAAIC,oCAAA,CAAsB,OAAc,CAAQ,CAAA;AAAA,EACxD,CAAA;AAAA,EACA,IAAA,EAAM,OAAO,EAAE,IAAA,IAAQ,GAAA,KAAQ;AAE7B,IAAA,MAAM,GAAA,CAAIC,0BAAA,CAAY,IAAW,CAAQ,CAAA;AAAA,EAC3C;AACF,CAAC;AAEM,MAAM,MAAA,GAASC,aAAA,CAAiB,MAAA,CAAOC,uCAAwB;AA+B/D,MAAM,YAAA,GAAeC;;;;;;;;;;;;;;;;;;;;;;;"}
|