-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): add overlay-type-errors case (#4271)
- Loading branch information
1 parent
4275ba2
commit c6e454e
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This is a type error | ||
let num = 1; | ||
num = '2'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.