Skip to content

Commit

Permalink
fix: wait domcontentloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy committed Jan 26, 2025
1 parent 94e5557 commit 6c10701
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
27 changes: 5 additions & 22 deletions e2e/cases/server/overlay-type-errors/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
import { dev, gotoPage, proxyConsole } from '@e2e/helper';
import { dev, getHrefByEntryName, proxyConsole } from '@e2e/helper';
import { expect, test } from '@playwright/test';
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';

const cwd = __dirname;

test('should display type errors on overlay correctly', async ({ page }) => {
const { restore } = proxyConsole();

let tsCheckDoneResolve: () => void;
const waitTsCheckDone = new Promise<void>((resolve) => {
tsCheckDoneResolve = resolve;
});

const rsbuild = await dev({
cwd,
plugins: [
pluginTypeCheck({
forkTsCheckerOptions: {
logger: {
log: console.log,
error: (...args: any[]) => {
tsCheckDoneResolve();
return console.error(...args);
},
},
},
}),
],
waitFirstCompileDone: false,
});

await waitTsCheckDone;
const url = getHrefByEntryName('index', rsbuild.port);

await page.goto(url, { waitUntil: 'domcontentloaded' });

await gotoPage(page, rsbuild);
const errorOverlay = page.locator('rsbuild-error-overlay');

await expect(errorOverlay.locator('.title')).toHaveText('Build failed');
Expand Down
6 changes: 6 additions & 0 deletions e2e/cases/server/overlay-type-errors/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from '@rsbuild/core';
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';

export default defineConfig({
plugins: [pluginTypeCheck()],
});

0 comments on commit 6c10701

Please sign in to comment.