Skip to content

Commit

Permalink
test(e2e): add overlay-type-errors case (#4271)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Dec 25, 2024
1 parent 4275ba2 commit c6e454e
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
33 changes: 33 additions & 0 deletions e2e/cases/server/overlay-type-errors/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { dev, proxyConsole } from '@e2e/helper';
import { expect, test } from '@playwright/test';

const cwd = __dirname;

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

const rsbuild = await dev({
cwd,
page,
});

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

await expect(errorOverlay.locator('.title')).toHaveText('Build failed');

// The first span is "<span style="color:#888">TS2322: </span>"
const firstSpan = errorOverlay.locator('span').first();
expect(await firstSpan.textContent()).toEqual('TS2322: ');
expect(await firstSpan.getAttribute('style')).toEqual('color:#888');

// The first link is "<a class="file-link">/src/index.ts:3:1</a>"
const firstLink = errorOverlay.locator('.file-link').first();
expect(await firstLink.getAttribute('class')).toEqual('file-link');
expect(
(await firstLink.textContent())?.endsWith('/src/index.ts:3:1'),
).toBeTruthy();

await rsbuild.close();

restore();
});
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()],
});
3 changes: 3 additions & 0 deletions e2e/cases/server/overlay-type-errors/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This is a type error
let num = 1;
num = '2';
12 changes: 12 additions & 0 deletions e2e/cases/server/overlay-type-errors/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["DOM", "ES2020"],
"module": "ESNext",
"strict": true,
"skipLibCheck": true,
"isolatedModules": true,
"moduleResolution": "Bundler"
},
"include": ["src"]
}
1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@rsbuild/plugin-stylus": "workspace:*",
"@rsbuild/plugin-svelte": "workspace:*",
"@rsbuild/plugin-svgr": "workspace:*",
"@rsbuild/plugin-type-check": "^1.2.0",
"@rsbuild/plugin-webpack-swc": "workspace:*",
"@rsbuild/plugin-vue": "workspace:*",
"@rsbuild/plugin-vue-jsx": "^1.1.0",
Expand Down
45 changes: 45 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6e454e

Please sign in to comment.