Skip to content

Commit

Permalink
test: should wait first compile done when run dev tests (#4429)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored Jan 24, 2025
1 parent adb9c3a commit 12c84a1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions e2e/scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const unwrapOutputJSON = async (distPath: string, ignoreMap = true) => {
export async function dev({
plugins,
page,
waitFirstCompileDone = true,
...options
}: CreateRsbuildOptions & {
plugins?: RsbuildPlugins;
Expand All @@ -147,6 +148,12 @@ export async function dev({
* This method will automatically goto the page.
*/
page?: Page;
/**
* The done of `dev` does not mean the compile is done.
* If your test relies on the completion of compilation you should `waitFirstCompileDone`
* @default true
*/
waitFirstCompileDone?: boolean;
}) {
process.env.NODE_ENV = 'development';

Expand Down Expand Up @@ -178,8 +185,21 @@ export async function dev({
},
]);

const wait = waitFirstCompileDone
? new Promise<void>((resolve) => {
rsbuild.onDevCompileDone(({ isFirstCompile }) => {
if (!isFirstCompile) {
return;
}
resolve();
});
})
: Promise.resolve();

const result = await rsbuild.startDevServer();

await wait;

if (page) {
await gotoPage(page, result);
}
Expand Down

1 comment on commit 12c84a1

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
plugins ✅ success
rspress ✅ success
rslib ✅ success
examples ✅ success

Please sign in to comment.