Skip to content

Commit cbafd9e

Browse files
committed
test(e2e): improve plugin watch hook test reliability
1 parent bc81188 commit cbafd9e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

e2e/cases/plugin-api/plugin-hooks-watch/index.test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs';
22
import { join } from 'node:path';
3-
import { rspackOnlyTest } from '@e2e/helper';
3+
import { expectFile, rspackOnlyTest } from '@e2e/helper';
44
import { expect } from '@playwright/test';
55
import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core';
66
import fse from 'fs-extra';
@@ -70,7 +70,9 @@ rspackOnlyTest(
7070
fse.ensureDirSync(join(cwd, 'test-temp-src'));
7171

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

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

7678
const { plugin, names } = createPlugin();
@@ -93,10 +95,11 @@ rspackOnlyTest(
9395
});
9496

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

100+
await fs.promises.rm(distPath, { recursive: true, force: true });
97101
await fs.promises.writeFile(filePath, "console.log('2');");
98-
99-
await new Promise((resolve) => setTimeout(resolve, 1000));
102+
await expectFile(distPath);
100103

101104
expect(names).toEqual([
102105
'ModifyRsbuildConfig',

0 commit comments

Comments
 (0)