diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index 5240f436f..7a9c58aa3 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -96,6 +96,7 @@ "esbuild": "0.14.43", "esbuild-runner": "2.2.1", "eslint": "8.17.0", + "eslint-plugin-react": "^7.29.4", "jest-image-snapshot": "^5.2.0", "npm-run-all": "^4.1.5", "playwright-chromium": "1.21.1", diff --git a/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/manifest.json b/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/manifest.json index 36a3b14b0..8c2204e4d 100644 --- a/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/manifest.json +++ b/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/manifest.json @@ -6,7 +6,7 @@ "content_scripts": [ { "matches": ["https://example.com/*"], - "js": ["src/main.ts"] + "js": ["src/content.ts"] } ], "options_page": "src/options.html", diff --git a/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/src1/main.ts b/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/src1/content.ts similarity index 100% rename from packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/src1/main.ts rename to packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/src1/content.ts diff --git a/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/vite-serve.test.ts b/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/vite-serve.test.ts index e0745828a..5c63853dd 100644 --- a/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/vite-serve.test.ts +++ b/packages/vite-plugin/tests/e2e/mv3-vite-vanilla-content-script-hmr/vite-serve.test.ts @@ -1,6 +1,7 @@ import fs from 'fs-extra' import path from 'path' -import { firstValueFrom } from 'rxjs' +import { ChromiumBrowserContext, Page, Route } from 'playwright-chromium' +import { firstValueFrom, Observable } from 'rxjs' import { expect, test } from 'vitest' import { getPage, waitForInnerHtml } from '../helpers' import { serve } from '../runners' @@ -13,11 +14,22 @@ test( const src1 = path.join(__dirname, 'src1') const src2 = path.join(__dirname, 'src2') - await fs.remove(src) - await fs.copy(src1, src, { recursive: true }) - - const { browser, routes } = await serve(__dirname) - const optionsPage = await getPage(browser, /options.html$/) + let browser: ChromiumBrowserContext | undefined + let routes: Observable | undefined + let optionsPage: Page | undefined + do { + try { + await fs.remove(src) + await fs.copy(src1, src, { recursive: true }) + + const result = await serve(__dirname) + browser = result.browser + routes = result.routes + optionsPage = await getPage(browser, /options.html$/) + } catch (error) { + console.error('Unable to get options page') + } + } while (!(browser && routes && optionsPage)) const page = await browser.newPage() await page.goto('https://example.com') @@ -43,8 +55,6 @@ test( }, }) - console.log('copy 1') - await waitForInnerHtml(styles, (h) => h.includes('background-color: red;')) expect(reloads).toBe(0) // no reload on css update expect(optionsPage.isClosed()).toBe(false) // no runtime reload on css update @@ -58,14 +68,10 @@ test( }, }) - console.log('copy 2') - await page.locator('h1', { hasText: header }).waitFor() expect(reloads).toBeGreaterThanOrEqual(1) // full reload on jsx update expect(optionsPage.isClosed()).toBe(false) // no runtime reload on js update - console.log('pre-copy 3') - // update background.ts file -> trigger runtime reload await Promise.all([ optionsPage.waitForEvent('close', { timeout: 5000 }), @@ -79,8 +85,6 @@ test( }), ]) - console.log('copy 3') - await app.waitFor() expect(optionsPage.isClosed()).toBe(true) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9ba18420..0ef138bdc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -185,6 +185,7 @@ importers: esbuild: 0.14.43 esbuild-runner: 2.2.1 eslint: 8.17.0 + eslint-plugin-react: ^7.29.4 fast-glob: ^3.2.11 fs-extra: ^10.0.1 jest-image-snapshot: ^5.2.0 @@ -244,6 +245,7 @@ importers: esbuild: 0.14.43 esbuild-runner: 2.2.1_esbuild@0.14.43 eslint: 8.17.0 + eslint-plugin-react: 7.29.4_eslint@8.17.0 jest-image-snapshot: 5.2.0 npm-run-all: 4.1.5 playwright-chromium: 1.21.1 @@ -6657,7 +6659,6 @@ packages: es-abstract: 1.19.5 get-intrinsic: 1.1.1 is-string: 1.0.7 - dev: false /array-union/2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} @@ -6681,7 +6682,6 @@ packages: define-properties: 1.1.4 es-abstract: 1.19.5 es-shim-unscopables: 1.0.0 - dev: false /arrify/1.0.1: resolution: {integrity: sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=} @@ -8515,7 +8515,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: esutils: 2.0.3 - dev: false /doctrine/3.0.0: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} @@ -8770,7 +8769,6 @@ packages: resolution: {integrity: sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==} dependencies: has: 1.0.3 - dev: false /es-to-primitive/1.2.1: resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} @@ -9476,7 +9474,6 @@ packages: resolve: 2.0.0-next.3 semver: 6.3.0 string.prototype.matchall: 4.0.7 - dev: false /eslint-scope/5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} @@ -10125,7 +10122,6 @@ packages: /functions-have-names/1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - dev: false /gensync/1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} @@ -12295,7 +12291,6 @@ packages: dependencies: array-includes: 3.1.5 object.assign: 4.1.2 - dev: false /keyv/3.1.0: resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==} @@ -13316,7 +13311,6 @@ packages: call-bind: 1.0.2 define-properties: 1.1.4 es-abstract: 1.19.5 - dev: false /object.fromentries/2.0.5: resolution: {integrity: sha512-CAyG5mWQRRiBU57Re4FKoTBjXfDoNwdFVH2Y1tS9PqCsfUTymAohOkEMSG3aRNKmv4lV3O7p1et7c187q6bynw==} @@ -13325,14 +13319,12 @@ packages: call-bind: 1.0.2 define-properties: 1.1.4 es-abstract: 1.19.5 - dev: false /object.hasown/1.1.1: resolution: {integrity: sha512-LYLe4tivNQzq4JdaWW6WO3HMZZJWzkkH8fnI6EebWl0VZth2wL2Lovm74ep2/gZzlaTdV62JZHEqHQ2yVn8Q/A==} dependencies: define-properties: 1.1.4 es-abstract: 1.19.5 - dev: false /object.pick/1.3.0: resolution: {integrity: sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=} @@ -13348,7 +13340,6 @@ packages: call-bind: 1.0.2 define-properties: 1.1.4 es-abstract: 1.19.5 - dev: false /obuf/1.1.2: resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} @@ -15108,7 +15099,6 @@ packages: call-bind: 1.0.2 define-properties: 1.1.4 functions-have-names: 1.2.3 - dev: false /regexpp/3.2.0: resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} @@ -15313,9 +15303,8 @@ packages: /resolve/2.0.0-next.3: resolution: {integrity: sha512-W8LucSynKUIDu9ylraa7ueVZ7hc0uAgJBxVsQSKOXOyle8a93qXhcz+XAXZ8bIq2d6i4Ehddn6Evt+0/UwKk6Q==} dependencies: - is-core-module: 2.8.1 + is-core-module: 2.10.0 path-parse: 1.0.7 - dev: false /responselike/1.0.2: resolution: {integrity: sha512-/Fpe5guzJk1gPqdJLJR5u7eG/gNY4nImjbRDaVWVMRhne55TCmj2i9Q+54PBRfatRC8v/rIiv9BN0pMd9OV5EQ==} @@ -16067,7 +16056,6 @@ packages: internal-slot: 1.0.3 regexp.prototype.flags: 1.4.3 side-channel: 1.0.4 - dev: false /string.prototype.padend/3.1.3: resolution: {integrity: sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==}