playwright-checkpoint 0.1.0-beta.0 → 0.3.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.
- package/dist/cli/bin.cjs +1 -1
- package/dist/cli/bin.cjs.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.cjs +1 -1
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -89,6 +89,6 @@ declare function orderedCheckpointNames(runs: RunRecord[]): string[];
|
|
|
89
89
|
|
|
90
90
|
declare function annotateScreenshot(imagePath: string, bounds: BoundingBox, outputPath: string): Promise<string | null>;
|
|
91
91
|
|
|
92
|
-
declare const VERSION = "0.1.0
|
|
92
|
+
declare const VERSION = "0.1.0";
|
|
93
93
|
|
|
94
94
|
export { BoundingBox, CheckpointCollector, CheckpointConfig, CheckpointManifest, CheckpointOptions, CheckpointRecord, type DeviceProfile, ReportGenerator, RunRecord, TestCheckpointConfig, type TestCheckpointConfigController, VERSION, annotateScreenshot, ariaSnapshotCollector, axeCollector, captureCheckpointRecord, collectTags, consoleCollector, createCheckpoint, createCheckpointManifestRecord, createDeviceProfile, domStatsCollector, expect, formsCollector, groupByStory, htmlCollector, htmlReporter, manifestTags, markdownReporter, mdxReporter, metadataCollector, networkCollector, networkTimingCollector, orderedCheckpointNames, screenshotCollector, setAxeLoaderForTests, storageCollector, test, titleParts, webVitalsCollector, writeCheckpointManifest };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,6 @@ declare function orderedCheckpointNames(runs: RunRecord[]): string[];
|
|
|
89
89
|
|
|
90
90
|
declare function annotateScreenshot(imagePath: string, bounds: BoundingBox, outputPath: string): Promise<string | null>;
|
|
91
91
|
|
|
92
|
-
declare const VERSION = "0.1.0
|
|
92
|
+
declare const VERSION = "0.1.0";
|
|
93
93
|
|
|
94
94
|
export { BoundingBox, CheckpointCollector, CheckpointConfig, CheckpointManifest, CheckpointOptions, CheckpointRecord, type DeviceProfile, ReportGenerator, RunRecord, TestCheckpointConfig, type TestCheckpointConfigController, VERSION, annotateScreenshot, ariaSnapshotCollector, axeCollector, captureCheckpointRecord, collectTags, consoleCollector, createCheckpoint, createCheckpointManifestRecord, createDeviceProfile, domStatsCollector, expect, formsCollector, groupByStory, htmlCollector, htmlReporter, manifestTags, markdownReporter, mdxReporter, metadataCollector, networkCollector, networkTimingCollector, orderedCheckpointNames, screenshotCollector, setAxeLoaderForTests, storageCollector, test, titleParts, webVitalsCollector, writeCheckpointManifest };
|
package/dist/index.js
CHANGED
|
@@ -172,7 +172,7 @@ function createCheckpoint(globalConfig = {}) {
|
|
|
172
172
|
const base = playwright.test;
|
|
173
173
|
const test2 = base.extend({
|
|
174
174
|
checkpointManifest: [
|
|
175
|
-
async (
|
|
175
|
+
async ({}, use, testInfo) => {
|
|
176
176
|
const manifest = createCheckpointManifestRecord(testInfo);
|
|
177
177
|
try {
|
|
178
178
|
await use(manifest);
|
|
@@ -186,7 +186,7 @@ function createCheckpoint(globalConfig = {}) {
|
|
|
186
186
|
},
|
|
187
187
|
{ auto: true }
|
|
188
188
|
],
|
|
189
|
-
testCheckpointConfig: async (
|
|
189
|
+
testCheckpointConfig: async ({}, use) => {
|
|
190
190
|
let current = null;
|
|
191
191
|
const controller = {
|
|
192
192
|
set(config) {
|
|
@@ -201,7 +201,7 @@ function createCheckpoint(globalConfig = {}) {
|
|
|
201
201
|
};
|
|
202
202
|
await use(controller);
|
|
203
203
|
},
|
|
204
|
-
deviceProfile: async (
|
|
204
|
+
deviceProfile: async ({}, use, testInfo) => {
|
|
205
205
|
await use(createDeviceProfile(testInfo));
|
|
206
206
|
},
|
|
207
207
|
checkpoint: async ({ page, checkpointManifest, testCheckpointConfig }, use, testInfo) => {
|
|
@@ -231,7 +231,7 @@ var { test } = createCheckpoint();
|
|
|
231
231
|
registerBuiltinCollectors(builtinCollectors);
|
|
232
232
|
|
|
233
233
|
// src/index.ts
|
|
234
|
-
var VERSION = "0.1.0
|
|
234
|
+
var VERSION = "0.1.0";
|
|
235
235
|
export {
|
|
236
236
|
VERSION,
|
|
237
237
|
annotateScreenshot,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fixture.ts","../src/device-profile.ts","../src/collectors/index.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport type * as PlaywrightModule from '@playwright/test';\nimport type {\n Page,\n PlaywrightTestArgs,\n PlaywrightTestOptions,\n PlaywrightWorkerArgs,\n PlaywrightWorkerOptions,\n TestInfo,\n TestType,\n} from '@playwright/test';\nimport {\n createCheckpointSession,\n registerBuiltinCollector,\n resolveCollectors,\n sanitizeSegment,\n settlePage,\n warn,\n} from './core';\nimport { createDeviceProfile, type DeviceProfile } from './device-profile';\nimport type {\n CheckpointConfig,\n CheckpointManifest,\n CheckpointOptions,\n CheckpointRecord,\n CollectorConfig,\n CollectorOptions,\n TestCheckpointConfig,\n} from './types';\n\ntype PlaywrightRuntime = typeof PlaywrightModule;\n\ntype TestCheckpointConfigController = {\n set(config: TestCheckpointConfig): void;\n get(): TestCheckpointConfig | null;\n};\n\ntype CheckpointFixtures = {\n checkpoint: (name: string, options?: CheckpointOptions) => Promise<CheckpointRecord>;\n checkpointManifest: CheckpointManifest;\n testCheckpointConfig: TestCheckpointConfigController;\n deviceProfile: DeviceProfile;\n};\n\nconst require = (() => {\n try {\n return Function('return require')() as NodeRequire;\n } catch {\n return createRequire(path.join(process.cwd(), 'playwright-checkpoint-runtime.cjs'));\n }\n})();\n\nfunction loadPlaywright(): PlaywrightRuntime {\n return require('@playwright/test') as PlaywrightRuntime;\n}\n\nfunction mergeCollectorOverrides(\n current: Partial<Record<string, boolean | CollectorOptions>> | undefined,\n updates: Partial<Record<string, boolean | CollectorOptions>> | undefined,\n): Partial<Record<string, boolean | CollectorOptions>> | undefined {\n if (!current && !updates) {\n return undefined;\n }\n\n const merged: Partial<Record<string, boolean | CollectorOptions>> = {\n ...(current ?? {}),\n };\n\n for (const [name, value] of Object.entries(updates ?? {})) {\n const previous = merged[name];\n\n if (value && typeof value === 'object' && !Array.isArray(value) && previous && typeof previous === 'object' && !Array.isArray(previous)) {\n merged[name] = {\n ...previous,\n ...value,\n };\n continue;\n }\n\n merged[name] = value;\n }\n\n return merged;\n}\n\nfunction mergeTestConfig(current: TestCheckpointConfig | null, update: TestCheckpointConfig): TestCheckpointConfig {\n const collectors = mergeCollectorOverrides(current?.collectors, update.collectors);\n\n return {\n description: update.description ?? current?.description,\n ...(collectors ? { collectors } : {}),\n };\n}\n\nfunction manifestEnvironment(): string {\n return process.env.PLAYWRIGHT_CHECKPOINT_ENV || process.env.NODE_ENV || 'test';\n}\n\nfunction explicitTestTags(testInfo: TestInfo): string[] {\n return (((testInfo as TestInfo & { tags?: string[] }).tags ?? []) as string[]).map((tag) => tag.toLowerCase());\n}\n\nexport function titleParts(testInfo: TestInfo): string[] {\n const maybeTitlePath = (testInfo as { titlePath?: unknown }).titlePath;\n return typeof maybeTitlePath === 'function' ? maybeTitlePath.call(testInfo) : [testInfo.title];\n}\n\nexport function collectTags(parts: string[]): Set<string> {\n const tags = new Set<string>();\n\n for (const part of parts) {\n for (const token of part.match(/@[a-z0-9-]+/gi) || []) {\n tags.add(token.toLowerCase());\n }\n }\n\n return tags;\n}\n\nexport function manifestTags(testInfo: TestInfo): string[] {\n return Array.from(new Set([...explicitTestTags(testInfo), ...collectTags(titleParts(testInfo))]));\n}\n\nexport function createCheckpointManifestRecord(testInfo: TestInfo): CheckpointManifest {\n return {\n environment: manifestEnvironment(),\n project: testInfo.project.name,\n testId: testInfo.testId,\n title: testInfo.title,\n tags: manifestTags(testInfo),\n startedAt: new Date().toISOString(),\n checkpoints: [],\n };\n}\n\nexport async function writeCheckpointManifest(testInfo: TestInfo, manifest: CheckpointManifest): Promise<string> {\n const manifestPath = testInfo.outputPath('checkpoint-manifest.json');\n await fs.mkdir(path.dirname(manifestPath), { recursive: true });\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`, 'utf8');\n return manifestPath;\n}\n\nfunction createAdjustTimeout(testInfo: TestInfo): (ms: number) => void {\n return (ms: number) => {\n if (ms > 0 && typeof testInfo.setTimeout === 'function') {\n testInfo.setTimeout(testInfo.timeout + ms);\n }\n };\n}\n\nfunction mergeConfig(\n globalConfig: CheckpointConfig = {},\n testConfig: TestCheckpointConfig | null,\n): Partial<Record<string, boolean | CollectorConfig>> | undefined {\n return mergeCollectorOverrides(\n globalConfig.collectors,\n testConfig?.collectors,\n ) as Partial<Record<string, boolean | CollectorConfig>> | undefined;\n}\n\nexport async function captureCheckpointRecord(args: {\n globalConfig?: CheckpointConfig;\n page: Page;\n testInfo: TestInfo;\n checkpointManifest: CheckpointManifest;\n testConfig?: TestCheckpointConfig | null;\n name: string;\n options?: CheckpointOptions;\n}): Promise<CheckpointRecord> {\n const globalConfig = args.globalConfig ?? {};\n const session = await createCheckpointSession(args.page, {\n outputDir: args.testInfo.outputPath('checkpoints'),\n manifestPath: args.testInfo.outputPath('checkpoint-manifest.json'),\n manifest: args.checkpointManifest,\n collectors: mergeConfig(globalConfig, args.testConfig ?? null),\n custom: globalConfig.custom,\n redact: globalConfig.redact,\n testInfo: args.testInfo,\n adjustTimeout: createAdjustTimeout(args.testInfo),\n });\n\n try {\n return await session.checkpoint(args.name, args.options);\n } finally {\n await session.finalize();\n }\n}\n\nexport function createCheckpoint(globalConfig: CheckpointConfig = {}): {\n test: TestType<PlaywrightTestArgs & PlaywrightTestOptions & CheckpointFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;\n} {\n const playwright = loadPlaywright();\n const base = playwright.test as TestType<\n PlaywrightTestArgs & PlaywrightTestOptions,\n PlaywrightWorkerArgs & PlaywrightWorkerOptions\n >;\n\n const test = base.extend<CheckpointFixtures>({\n checkpointManifest: [\n async (_fixtures, use, testInfo) => {\n const manifest = createCheckpointManifestRecord(testInfo);\n\n try {\n await use(manifest);\n } finally {\n try {\n await writeCheckpointManifest(testInfo, manifest);\n } catch (error) {\n warn(`Failed to write checkpoint manifest for test \"${testInfo.title}\".`, error);\n }\n }\n },\n { auto: true },\n ],\n\n testCheckpointConfig: async (_fixtures, use) => {\n let current: TestCheckpointConfig | null = null;\n\n const controller: TestCheckpointConfigController = {\n set(config) {\n current = mergeTestConfig(current, config);\n },\n get() {\n return current\n ? {\n ...current,\n ...(current.collectors ? { collectors: mergeCollectorOverrides(undefined, current.collectors) } : {}),\n }\n : null;\n },\n };\n\n await use(controller);\n },\n\n deviceProfile: async (_fixtures, use, testInfo) => {\n await use(createDeviceProfile(testInfo));\n },\n\n checkpoint: async ({ page, checkpointManifest, testCheckpointConfig }, use, testInfo) => {\n const session = await createCheckpointSession(page, {\n outputDir: testInfo.outputPath('checkpoints'),\n manifestPath: testInfo.outputPath('checkpoint-manifest.json'),\n manifest: checkpointManifest,\n collectors: mergeConfig(globalConfig, testCheckpointConfig.get()),\n custom: globalConfig.custom,\n redact: globalConfig.redact,\n testInfo,\n adjustTimeout: createAdjustTimeout(testInfo),\n });\n\n try {\n await use((name, options = {}) => session.checkpoint(name, options));\n } finally {\n await session.finalize();\n }\n },\n });\n\n return { test };\n}\n\nexport const expect = loadPlaywright().expect;\nexport const { test } = createCheckpoint();\nexport { createCheckpointSession, createDeviceProfile, registerBuiltinCollector, resolveCollectors, sanitizeSegment, settlePage, warn };\nexport type { DeviceProfile, TestCheckpointConfigController };\n","import type { TestInfo } from '@playwright/test';\n\nexport type DeviceSurface = 'desktop' | 'mobile';\n\nexport type DeviceProfile = {\n name: string;\n isMobile: boolean;\n surface: DeviceSurface;\n};\n\nexport function createDeviceProfile(testInfo: TestInfo): DeviceProfile {\n const use = testInfo.project.use as { isMobile?: boolean } | undefined;\n const isMobile = Boolean(use?.isMobile);\n\n return {\n name: testInfo.project.name,\n isMobile,\n surface: isMobile ? 'mobile' : 'desktop',\n };\n}\n","import { builtinCollectors } from './builtin-collectors';\nimport { registerBuiltinCollectors } from './registry';\n\nregisterBuiltinCollectors(builtinCollectors);\n\nexport { registerBuiltinCollector, registerBuiltinCollectors, getBuiltinCollectors } from './registry';\nexport { screenshotCollector } from './screenshot';\nexport { htmlCollector } from './html';\nexport { axeCollector, setAxeLoaderForTests } from './axe';\nexport { webVitalsCollector } from './web-vitals';\nexport { consoleCollector } from './console';\nexport { networkCollector } from './network';\nexport { metadataCollector } from './metadata';\nexport { ariaSnapshotCollector } from './aria-snapshot';\nexport { domStatsCollector } from './dom-stats';\nexport { formsCollector } from './forms';\nexport { storageCollector } from './storage';\nexport { networkTimingCollector } from './network-timing';\nexport type { CheckpointCollector } from '../types';\n","export type * from './types';\nexport * from './core';\nexport * from './fixture';\nexport { type CheckpointCollector } from './types';\nexport { type ReportGenerator } from './types';\nexport * from './collectors';\nexport * from './report';\n\nexport const VERSION = '0.1.0-beta.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,OAAO,UAAU;;;ACQV,SAAS,oBAAoB,UAAmC;AACrE,QAAM,MAAM,SAAS,QAAQ;AAC7B,QAAM,WAAW,QAAQ,KAAK,QAAQ;AAEtC,SAAO;AAAA,IACL,MAAM,SAAS,QAAQ;AAAA,IACvB;AAAA,IACA,SAAS,WAAW,WAAW;AAAA,EACjC;AACF;;;AD2BA,IAAMA,YAAW,MAAM;AACrB,MAAI;AACF,WAAO,SAAS,gBAAgB,EAAE;AAAA,EACpC,QAAQ;AACN,WAAO,cAAc,KAAK,KAAK,QAAQ,IAAI,GAAG,mCAAmC,CAAC;AAAA,EACpF;AACF,GAAG;AAEH,SA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IAEA,YAAY,OAAO,EAAE,MAAM,oBAAoB,qBAAqB,GAAG,KAAK,aAAa;AACvF,YAAM,UAAU,MAAM,wBAAwB,MAAM;AAAA,QAClD,WAAW,SAAS,WAAW,aAAa;AAAA,QAC5C,cAAc,SAAS,WAAW,0BAA0B;AAAA,QAC5D,UAAU;AAAA,QACV,YAAY,YAAY,cAAc,qBAAqB,IAAI,CAAC;AAAA,QAChE,QAAQ,aAAa;AAAA,QACrB,QAAQ,aAAa;AAAA,QACrB;AAAA,QACA,eAAe,oBAAoB,QAAQ;AAAA,MAC7C,CAAC;AAED,UAAI;AACF,cAAM,IAAI,CAAC,MAAM,UAAU,CAAC,MAAM,QAAQ,WAAW,MAAM,OAAO,CAAC;AAAA,MACrE,UAAE;AACA,cAAM,QAAQ,SAAS;AAAA,MACzB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,EAAE,MAAAA,MAAK;AAChB;AAEO,IAAM,SAAS,eAAe,EAAE;AAChC,IAAM,EAAE,KAAK,IAAI,iBAAiB;;;AEtQzC,0BAA0B,iBAAiB;;;ACKpC,IAAM,UAAU;","names":["require","test"]}
|
|
1
|
+
{"version":3,"sources":["../src/fixture.ts","../src/device-profile.ts","../src/collectors/index.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport type * as PlaywrightModule from '@playwright/test';\nimport type {\n Page,\n PlaywrightTestArgs,\n PlaywrightTestOptions,\n PlaywrightWorkerArgs,\n PlaywrightWorkerOptions,\n TestInfo,\n TestType,\n} from '@playwright/test';\nimport {\n createCheckpointSession,\n registerBuiltinCollector,\n resolveCollectors,\n sanitizeSegment,\n settlePage,\n warn,\n} from './core';\nimport { createDeviceProfile, type DeviceProfile } from './device-profile';\nimport type {\n CheckpointConfig,\n CheckpointManifest,\n CheckpointOptions,\n CheckpointRecord,\n CollectorConfig,\n CollectorOptions,\n TestCheckpointConfig,\n} from './types';\n\ntype PlaywrightRuntime = typeof PlaywrightModule;\n\ntype TestCheckpointConfigController = {\n set(config: TestCheckpointConfig): void;\n get(): TestCheckpointConfig | null;\n};\n\ntype CheckpointFixtures = {\n checkpoint: (name: string, options?: CheckpointOptions) => Promise<CheckpointRecord>;\n checkpointManifest: CheckpointManifest;\n testCheckpointConfig: TestCheckpointConfigController;\n deviceProfile: DeviceProfile;\n};\n\nconst require = (() => {\n try {\n return Function('return require')() as NodeRequire;\n } catch {\n return createRequire(path.join(process.cwd(), 'playwright-checkpoint-runtime.cjs'));\n }\n})();\n\nfunction loadPlaywright(): PlaywrightRuntime {\n return require('@playwright/test') as PlaywrightRuntime;\n}\n\nfunction mergeCollectorOverrides(\n current: Partial<Record<string, boolean | CollectorOptions>> | undefined,\n updates: Partial<Record<string, boolean | CollectorOptions>> | undefined,\n): Partial<Record<string, boolean | CollectorOptions>> | undefined {\n if (!current && !updates) {\n return undefined;\n }\n\n const merged: Partial<Record<string, boolean | CollectorOptions>> = {\n ...(current ?? {}),\n };\n\n for (const [name, value] of Object.entries(updates ?? {})) {\n const previous = merged[name];\n\n if (value && typeof value === 'object' && !Array.isArray(value) && previous && typeof previous === 'object' && !Array.isArray(previous)) {\n merged[name] = {\n ...previous,\n ...value,\n };\n continue;\n }\n\n merged[name] = value;\n }\n\n return merged;\n}\n\nfunction mergeTestConfig(current: TestCheckpointConfig | null, update: TestCheckpointConfig): TestCheckpointConfig {\n const collectors = mergeCollectorOverrides(current?.collectors, update.collectors);\n\n return {\n description: update.description ?? current?.description,\n ...(collectors ? { collectors } : {}),\n };\n}\n\nfunction manifestEnvironment(): string {\n return process.env.PLAYWRIGHT_CHECKPOINT_ENV || process.env.NODE_ENV || 'test';\n}\n\nfunction explicitTestTags(testInfo: TestInfo): string[] {\n return (((testInfo as TestInfo & { tags?: string[] }).tags ?? []) as string[]).map((tag) => tag.toLowerCase());\n}\n\nexport function titleParts(testInfo: TestInfo): string[] {\n const maybeTitlePath = (testInfo as { titlePath?: unknown }).titlePath;\n return typeof maybeTitlePath === 'function' ? maybeTitlePath.call(testInfo) : [testInfo.title];\n}\n\nexport function collectTags(parts: string[]): Set<string> {\n const tags = new Set<string>();\n\n for (const part of parts) {\n for (const token of part.match(/@[a-z0-9-]+/gi) || []) {\n tags.add(token.toLowerCase());\n }\n }\n\n return tags;\n}\n\nexport function manifestTags(testInfo: TestInfo): string[] {\n return Array.from(new Set([...explicitTestTags(testInfo), ...collectTags(titleParts(testInfo))]));\n}\n\nexport function createCheckpointManifestRecord(testInfo: TestInfo): CheckpointManifest {\n return {\n environment: manifestEnvironment(),\n project: testInfo.project.name,\n testId: testInfo.testId,\n title: testInfo.title,\n tags: manifestTags(testInfo),\n startedAt: new Date().toISOString(),\n checkpoints: [],\n };\n}\n\nexport async function writeCheckpointManifest(testInfo: TestInfo, manifest: CheckpointManifest): Promise<string> {\n const manifestPath = testInfo.outputPath('checkpoint-manifest.json');\n await fs.mkdir(path.dirname(manifestPath), { recursive: true });\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`, 'utf8');\n return manifestPath;\n}\n\nfunction createAdjustTimeout(testInfo: TestInfo): (ms: number) => void {\n return (ms: number) => {\n if (ms > 0 && typeof testInfo.setTimeout === 'function') {\n testInfo.setTimeout(testInfo.timeout + ms);\n }\n };\n}\n\nfunction mergeConfig(\n globalConfig: CheckpointConfig = {},\n testConfig: TestCheckpointConfig | null,\n): Partial<Record<string, boolean | CollectorConfig>> | undefined {\n return mergeCollectorOverrides(\n globalConfig.collectors,\n testConfig?.collectors,\n ) as Partial<Record<string, boolean | CollectorConfig>> | undefined;\n}\n\nexport async function captureCheckpointRecord(args: {\n globalConfig?: CheckpointConfig;\n page: Page;\n testInfo: TestInfo;\n checkpointManifest: CheckpointManifest;\n testConfig?: TestCheckpointConfig | null;\n name: string;\n options?: CheckpointOptions;\n}): Promise<CheckpointRecord> {\n const globalConfig = args.globalConfig ?? {};\n const session = await createCheckpointSession(args.page, {\n outputDir: args.testInfo.outputPath('checkpoints'),\n manifestPath: args.testInfo.outputPath('checkpoint-manifest.json'),\n manifest: args.checkpointManifest,\n collectors: mergeConfig(globalConfig, args.testConfig ?? null),\n custom: globalConfig.custom,\n redact: globalConfig.redact,\n testInfo: args.testInfo,\n adjustTimeout: createAdjustTimeout(args.testInfo),\n });\n\n try {\n return await session.checkpoint(args.name, args.options);\n } finally {\n await session.finalize();\n }\n}\n\nexport function createCheckpoint(globalConfig: CheckpointConfig = {}): {\n test: TestType<PlaywrightTestArgs & PlaywrightTestOptions & CheckpointFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;\n} {\n const playwright = loadPlaywright();\n const base = playwright.test as TestType<\n PlaywrightTestArgs & PlaywrightTestOptions,\n PlaywrightWorkerArgs & PlaywrightWorkerOptions\n >;\n\n const test = base.extend<CheckpointFixtures>({\n checkpointManifest: [\n async ({}, use, testInfo) => {\n const manifest = createCheckpointManifestRecord(testInfo);\n\n try {\n await use(manifest);\n } finally {\n try {\n await writeCheckpointManifest(testInfo, manifest);\n } catch (error) {\n warn(`Failed to write checkpoint manifest for test \"${testInfo.title}\".`, error);\n }\n }\n },\n { auto: true },\n ],\n\n testCheckpointConfig: async ({}, use) => {\n let current: TestCheckpointConfig | null = null;\n\n const controller: TestCheckpointConfigController = {\n set(config) {\n current = mergeTestConfig(current, config);\n },\n get() {\n return current\n ? {\n ...current,\n ...(current.collectors ? { collectors: mergeCollectorOverrides(undefined, current.collectors) } : {}),\n }\n : null;\n },\n };\n\n await use(controller);\n },\n\n deviceProfile: async ({}, use, testInfo) => {\n await use(createDeviceProfile(testInfo));\n },\n\n checkpoint: async ({ page, checkpointManifest, testCheckpointConfig }, use, testInfo) => {\n const session = await createCheckpointSession(page, {\n outputDir: testInfo.outputPath('checkpoints'),\n manifestPath: testInfo.outputPath('checkpoint-manifest.json'),\n manifest: checkpointManifest,\n collectors: mergeConfig(globalConfig, testCheckpointConfig.get()),\n custom: globalConfig.custom,\n redact: globalConfig.redact,\n testInfo,\n adjustTimeout: createAdjustTimeout(testInfo),\n });\n\n try {\n await use((name, options = {}) => session.checkpoint(name, options));\n } finally {\n await session.finalize();\n }\n },\n });\n\n return { test };\n}\n\nexport const expect = loadPlaywright().expect;\nexport const { test } = createCheckpoint();\nexport { createCheckpointSession, createDeviceProfile, registerBuiltinCollector, resolveCollectors, sanitizeSegment, settlePage, warn };\nexport type { DeviceProfile, TestCheckpointConfigController };\n","import type { TestInfo } from '@playwright/test';\n\nexport type DeviceSurface = 'desktop' | 'mobile';\n\nexport type DeviceProfile = {\n name: string;\n isMobile: boolean;\n surface: DeviceSurface;\n};\n\nexport function createDeviceProfile(testInfo: TestInfo): DeviceProfile {\n const use = testInfo.project.use as { isMobile?: boolean } | undefined;\n const isMobile = Boolean(use?.isMobile);\n\n return {\n name: testInfo.project.name,\n isMobile,\n surface: isMobile ? 'mobile' : 'desktop',\n };\n}\n","import { builtinCollectors } from './builtin-collectors';\nimport { registerBuiltinCollectors } from './registry';\n\nregisterBuiltinCollectors(builtinCollectors);\n\nexport { registerBuiltinCollector, registerBuiltinCollectors, getBuiltinCollectors } from './registry';\nexport { screenshotCollector } from './screenshot';\nexport { htmlCollector } from './html';\nexport { axeCollector, setAxeLoaderForTests } from './axe';\nexport { webVitalsCollector } from './web-vitals';\nexport { consoleCollector } from './console';\nexport { networkCollector } from './network';\nexport { metadataCollector } from './metadata';\nexport { ariaSnapshotCollector } from './aria-snapshot';\nexport { domStatsCollector } from './dom-stats';\nexport { formsCollector } from './forms';\nexport { storageCollector } from './storage';\nexport { networkTimingCollector } from './network-timing';\nexport type { CheckpointCollector } from '../types';\n","export type * from './types';\nexport * from './core';\nexport * from './fixture';\nexport { type CheckpointCollector } from './types';\nexport { type ReportGenerator } from './types';\nexport * from './collectors';\nexport * from './report';\n\nexport const VERSION = '0.1.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,OAAO,UAA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3C,YAAM,aAA6C;AAAA,QACjD,IAAI,QAAQ;AACV,oBAAU,gBAAgB,SAAS,MAAM;AAAA,QAC3C;AAAA,QACA,MAAM;AACJ,iBAAO,UACH;AAAA,YACE,GAAG;AAAA,YACH,GAAI,QAAQ,aAAa,EAAE,YAAY,wBAAwB,QAAW,QAAQ,UAAU,EAAE,IAAI,CAAC;AAAA,UACrG,IACA;AAAA,QACN;AAAA,MACF;AAEA,YAAM,IAAI,UAAU;AAAA,IACtB;AAAA,IAEA,eAAe,OAAO,CAAC,GAAG,KAAK,aAAa;AAC1C,YAAM,IAAI,oBAAoB,QAAQ,CAAC;AAAA,IACzC;AAAA,IAEA,YAAY,OAAO,EAAE,MAAM,oBAAoB,qBAAqB,GAAG,KAAK,aAAa;AACvF,YAAM,UAAU,MAAM,wBAAwB,MAAM;AAAA,QAClD,WAAW,SAAS,WAAW,aAAa;AAAA,QAC5C,cAAc,SAAS,WAAW,0BAA0B;AAAA,QAC5D,UAAU;AAAA,QACV,YAAY,YAAY,cAAc,qBAAqB,IAAI,CAAC;AAAA,QAChE,QAAQ,aAAa;AAAA,QACrB,QAAQ,aAAa;AAAA,QACrB;AAAA,QACA,eAAe,oBAAoB,QAAQ;AAAA,MAC7C,CAAC;AAED,UAAI;AACF,cAAM,IAAI,CAAC,MAAM,UAAU,CAAC,MAAM,QAAQ,WAAW,MAAM,OAAO,CAAC;AAAA,MACrE,UAAE;AACA,cAAM,QAAQ,SAAS;AAAA,MACzB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,EAAE,MAAAA,MAAK;AAChB;AAEO,IAAM,SAAS,eAAe,EAAE;AAChC,IAAM,EAAE,KAAK,IAAI,iBAAiB;;;AEtQzC,0BAA0B,iBAAiB;;;ACKpC,IAAM,UAAU;","names":["require","test"]}
|
package/dist/mcp/index.cjs
CHANGED
|
@@ -3400,7 +3400,7 @@ async function startMcpProxy(options = {}) {
|
|
|
3400
3400
|
inputSchema: t.inputSchema
|
|
3401
3401
|
}));
|
|
3402
3402
|
const allTools = [...checkpointTools, ...upstreamTools];
|
|
3403
|
-
const server = new Server({ name: "playwright-checkpoint", version: "0.1.0
|
|
3403
|
+
const server = new Server({ name: "playwright-checkpoint", version: "0.1.0" }, { capabilities: { tools: {} } });
|
|
3404
3404
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
3405
3405
|
return { tools: allTools };
|
|
3406
3406
|
});
|