Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: rebuild components on new vite (#17367)
Pavel Feldman30ff27843a6a
diff --git a/packages/playwright-core/src/common/userAgent.ts b/packages/playwright-core/src/common/userAgent.tsindex 604a85f082..b31cc04bc2 100644--- a/packages/playwright-core/src/common/userAgent.ts+++ b/packages/playwright-core/src/common/userAgent.ts@@ -75,7 +75,7 @@ export function getClientLanguage(): { langName: string, langVersion: string } {return { langName, langVersion };}-export function getPlaywrightVersion(majorMinorOnly = false) {+export function getPlaywrightVersion(majorMinorOnly = false): string {const packageJson = require('./../../package.json');return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;}diff --git a/packages/playwright-test/src/plugins/vitePlugin.ts b/packages/playwright-test/src/plugins/vitePlugin.tsindex 21593f80ef..99ea778672 100644--- a/packages/playwright-test/src/plugins/vitePlugin.ts+++ b/packages/playwright-test/src/plugins/vitePlugin.ts@@ -26,9 +26,10 @@ import { collectComponentUsages, componentInfo } from '../tsxTransform';import type { FullConfig } from '../types';import { assert, calculateSha1 } from 'playwright-core/lib/utils';import type { AddressInfo } from 'net';+import { getPlaywrightVersion } from 'playwright-core/lib/common/userAgent';let stoppableServer: any;-const VERSION = 6;+const playwrightVersion = getPlaywrightVersion();type CtConfig = {ctPort?: number;@@ -65,14 +66,17 @@ export function createPlugin(const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');const registerSourceHash = calculateSha1(registerSource);+ const { version: viteVersion } = require('vite/package.json');try {buildInfo = JSON.parse(await fs.promises.readFile(buildInfoFile, 'utf-8')) as BuildInfo;- assert(buildInfo.version === VERSION);+ assert(buildInfo.version === playwrightVersion);+ assert(buildInfo.viteVersion === viteVersion);assert(buildInfo.registerSourceHash === registerSourceHash);buildExists = true;} catch (e) {buildInfo = {- version: VERSION,+ version: playwrightVersion,+ viteVersion,registerSourceHash,components: [],tests: {},@@ -156,7 +160,8 @@ export function createPlugin(}type BuildInfo = {- version: number,+ version: string,+ viteVersion: string,registerSourceHash: string,sources: {[key: string]: {diff --git a/tests/playwright-test/playwright.ct-build.spec.ts b/tests/playwright-test/playwright.ct-build.spec.tsindex c36449f957..1e3ab5d6e6 100644--- a/tests/playwright-test/playwright.ct-build.spec.ts+++ b/tests/playwright-test/playwright.ct-build.spec.ts@@ -37,7 +37,8 @@ test('should work with the empty component list', async ({ runInlineTest }, testexpect(output.replace(/\\+/g, '/')).toContain('playwright/.cache/playwright/index.html');const metainfo = JSON.parse(fs.readFileSync(testInfo.outputPath('playwright/.cache/metainfo.json'), 'utf-8'));- expect(metainfo.version).toEqual(expect.any(Number));+ expect(metainfo.version).toEqual(require('playwright-core/package.json').version);+ expect(metainfo.viteVersion).toEqual(require('vite/package.json').version);expect(Object.entries(metainfo.tests)).toHaveLength(1);expect(Object.entries(metainfo.sources)).toHaveLength(8);});