diff --git a/boilerplates/.testRun.ts b/boilerplates/.testRun.ts index 494ec10067c..2f3afa79ea9 100644 --- a/boilerplates/.testRun.ts +++ b/boilerplates/.testRun.ts @@ -2,10 +2,7 @@ import { page, run, partRegex, autoRetry, fetchHtml, urlBase, expectBrowserError export { testRun } -function testRun( - cmd: 'npm run dev' | 'npm run prod', - { skipTitleColorTest }: { skipTitleColorTest?: boolean } = {}, -) { +function testRun(cmd: 'npm run dev' | 'npm run prod', { skipTitleColorTest }: { skipTitleColorTest?: boolean } = {}) { run(cmd) test('page content is rendered to HTML', async () => { @@ -32,9 +29,17 @@ function testRun( expect(html).toMatch( partRegex`') } else { expect(html).toContain('') diff --git a/examples/custom-server-render-integration/server/index.js b/examples/custom-server-render-integration/server/index.js index 35854c71ed6..ae336b3d9e3 100644 --- a/examples/custom-server-render-integration/server/index.js +++ b/examples/custom-server-render-integration/server/index.js @@ -67,18 +67,28 @@ function assert_pageAssets(pageAssets) { assert(a1.assetType === 'style') assert(a1.mediaType === 'text/css') assert(a1.preloadType === 'style') - const a2 = pageAssets[1] - assert(partRegex`/assets/vendor.${/[a-z0-9]+/}.js`.test(a2.src)) - assert(a2.assetType === 'preload') - assert(a2.mediaType === 'text/javascript') - assert(a2.preloadType === 'script') + + let a2 = pageAssets[1] + let a3 = pageAssets[2] + let a4 = pageAssets[3] + if (a4) { + // Vite 2.8 + assert(pageAssets.length === 4) + assert(partRegex`/assets/vendor.${/[a-z0-9]+/}.js`.test(a2.src)) + assert(a2.assetType === 'preload') + assert(a2.mediaType === 'text/javascript') + assert(a2.preloadType === 'script') + } else { + // Vite 2.9 + assert(pageAssets.length === 3) + a4 = a3 + a3 = a2 + } const isClientAsset = (src) => partRegex`/assets/renderer/_default.page.client.jsx.${/[a-z0-9]+/}.js`.test(src) - const a3 = pageAssets[2] assert(isClientAsset(a3.src)) assert(a3.assetType === 'preload') assert(a3.mediaType === 'text/javascript') assert(a3.preloadType === 'script') - const a4 = pageAssets[3] assert(isClientAsset(a4.src)) assert(a4.assetType === 'script') assert(a4.mediaType === 'text/javascript')