From eb58c7cacaae9742bff7dfb6abcd8348c2892061 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 9 Dec 2024 14:35:59 +0900 Subject: [PATCH] test: add test --- .../__tests__/basic.spec.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/playground/rolldown-dev-react/__tests__/basic.spec.ts b/playground/rolldown-dev-react/__tests__/basic.spec.ts index 193301c1de2385..342bf8c7677c88 100644 --- a/playground/rolldown-dev-react/__tests__/basic.spec.ts +++ b/playground/rolldown-dev-react/__tests__/basic.spec.ts @@ -1,4 +1,4 @@ -import { expect, test } from 'vitest' +import { expect, test, vi } from 'vitest' import { addFile, editFile, isBuild, page, viteTestUrl } from '../../test-utils' test('basic', async () => { @@ -92,3 +92,28 @@ test.runIf(!isBuild)('hmr new file', async () => { await page.getByRole('button', { name: 'Count-[new-file:ok]: 1' }).click() }) + +test('dynamic import chunk', async () => { + await page.goto(viteTestUrl) + await page.locator('.test-dynamic-import button').click() + await expect + .poll(() => page.textContent('.test-dynamic-import')) + .toContain('[ok]') +}) + +test.runIf(!isBuild)('dynamic import chunk update', async () => { + await page.goto(viteTestUrl) + editFile('./src/dynamic-import-dep.ts', (s) => s.replace('[ok]', '[ok-edit]')) + await vi.waitFor( + async () => { + await page.locator('.test-dynamic-import button').click() + await expect + .poll(() => page.textContent('.test-dynamic-import')) + .toContain('[ok-edit]') + }, + { + timeout: 2000, + interval: 500, + }, + ) +})