From 92cb12dfba3fa0f7fbaa42e8810b4e4c927740b1 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 18 Jun 2025 22:32:30 +0800 Subject: [PATCH] test(e2e): improve debug mode tests --- .../debug.test.ts => debug-mode/index.test.ts} | 15 ++++++--------- e2e/cases/config/debug-mode/src/index.js | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) rename e2e/cases/config/{inspect-config/debug.test.ts => debug-mode/index.test.ts} (83%) create mode 100644 e2e/cases/config/debug-mode/src/index.js diff --git a/e2e/cases/config/inspect-config/debug.test.ts b/e2e/cases/config/debug-mode/index.test.ts similarity index 83% rename from e2e/cases/config/inspect-config/debug.test.ts rename to e2e/cases/config/debug-mode/index.test.ts index fe277744e2..c2aae12e1e 100644 --- a/e2e/cases/config/inspect-config/debug.test.ts +++ b/e2e/cases/config/debug-mode/index.test.ts @@ -1,6 +1,6 @@ import fs from 'node:fs'; import path from 'node:path'; -import { build, dev, gotoPage } from '@e2e/helper'; +import { build, dev } from '@e2e/helper'; import { expect, test } from '@playwright/test'; import { logger } from '@rsbuild/core'; @@ -13,7 +13,7 @@ const getBundlerConfig = (dist: string) => `./${dist}/.rsbuild/${process.env.PROVIDE_TYPE || 'rspack'}.config.web.mjs`, ); -test('should generate config files when build (with DEBUG)', async () => { +test('should generate config files in debug mode when build', async () => { const { level } = logger; logger.level = 'verbose'; process.env.DEBUG = 'rsbuild'; @@ -26,7 +26,6 @@ test('should generate config files when build (with DEBUG)', async () => { distPath: { root: distRoot, }, - cleanDistPath: true, }, }, }); @@ -45,7 +44,9 @@ test('should generate config files when build (with DEBUG)', async () => { await close(); }); -test('should generate config files when dev (with DEBUG)', async ({ page }) => { +test('should generate config files in debug mode when dev', async ({ + page, +}) => { const { level } = logger; process.env.DEBUG = 'rsbuild'; logger.level = 'verbose'; @@ -58,15 +59,11 @@ test('should generate config files when dev (with DEBUG)', async ({ page }) => { distPath: { root: distRoot, }, - cleanDistPath: true, }, }, + page, }); - const res = await gotoPage(page, rsbuild); - - expect(res?.status()).toBe(200); - expect(fs.existsSync(getRsbuildConfig(distRoot))).toBeTruthy(); expect(fs.existsSync(getBundlerConfig(distRoot))).toBeTruthy(); diff --git a/e2e/cases/config/debug-mode/src/index.js b/e2e/cases/config/debug-mode/src/index.js new file mode 100644 index 0000000000..8b1a393741 --- /dev/null +++ b/e2e/cases/config/debug-mode/src/index.js @@ -0,0 +1 @@ +// empty