Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): improve plugin watch hook test reliability #4738

Merged
merged 1 commit into from
Mar 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions e2e/cases/plugin-api/plugin-hooks-watch/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs';
import { join } from 'node:path';
import { rspackOnlyTest } from '@e2e/helper';
import { expectFile, rspackOnlyTest } from '@e2e/helper';
import { expect } from '@playwright/test';
import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core';
import fse from 'fs-extra';
Expand Down Expand Up @@ -70,7 +70,9 @@ rspackOnlyTest(
fse.ensureDirSync(join(cwd, 'test-temp-src'));

const filePath = join(cwd, 'test-temp-src', 'index.js');
const distPath = join(cwd, 'dist/index.html');

await fs.promises.rm(distPath, { recursive: true, force: true });
await fs.promises.writeFile(filePath, "console.log('1');");

const { plugin, names } = createPlugin();
Expand All @@ -93,10 +95,11 @@ rspackOnlyTest(
});

const result = await rsbuild.build({ watch: true });
await expectFile(distPath);

await fs.promises.rm(distPath, { recursive: true, force: true });
await fs.promises.writeFile(filePath, "console.log('2');");

await new Promise((resolve) => setTimeout(resolve, 1000));
await expectFile(distPath);

expect(names).toEqual([
'ModifyRsbuildConfig',
Expand Down
Loading