-
Notifications
You must be signed in to change notification settings - Fork 169
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 test case for new web worker (#1576)
- Loading branch information
1 parent
7cfb0b0
commit b492547
Showing
8 changed files
with
30 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,15 @@ | ||
import path from 'node:path'; | ||
import { expect, test } from '@playwright/test'; | ||
import { build, gotoPage } from '@e2e/helper'; | ||
|
||
test('should allow to build web-worker with new Worker', async ({ page }) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
|
||
await gotoPage(page, rsbuild); | ||
await expect(page.locator('#root')).toHaveText( | ||
'The Answer to the Ultimate Question of Life, The Universe, and Everything: 42', | ||
); | ||
}); |
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,10 @@ | ||
const worker = new Worker(new URL('./worker.js', import.meta.url)); | ||
|
||
worker.postMessage({ | ||
question: | ||
'The Answer to the Ultimate Question of Life, The Universe, and Everything', | ||
}); | ||
|
||
worker.onmessage = ({ data: { answer } }) => { | ||
document.getElementById('root').innerHTML = answer; | ||
}; |
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,5 @@ | ||
self.onmessage = ({ data: { question } }) => { | ||
self.postMessage({ | ||
answer: `${question}: 42`, | ||
}); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.