[BUG] Playwright test runner always show test result pass when working with websocket (ws or sockiet io client)
See original GitHub issueContext:
- Playwright Version:“^1.27.1”
- Operating System: Linux (Ubuntu 22.04)
- Node.js version: v18.2.1
- Browser: request (API testing)
- Extra: “socket.io”: “^4.5.4”,“socket.io-client”: “^4.5.4”, “ws”: “^8.11.0”
Code Snippet
Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:
test(`check websocket available`, async({}) => {
const ws = new WebSocket(`${endpoint.WEBSOCKET_HOST}/notification/inapp/register`,{
headers: {
Cookie: `token=1${accessToken}`
}
});
ws.on('open', function (){
ws.send("say Donnnnnnnnnnn")
});
})
Describe the bug
When running the test, even inputting an invalid value into the cookie field, Playwright still shows the test result as pass. I checked with socket io client also, but still the result is pass. I guess there’s something wrong with Playwright test runner when working with WebSocket client.
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Performance issue and websocket error #158 - GitHub
My guess is there is something slow going on during startup because the first test result takes much longer to show up as...
Read more >WebSocket - Playwright
WebSocket. The WebSocket class represents websocket connections in the page. ... Fired when the websocket receives a frame.
Read more >WebSocket error when using Playwright on GitLab CI
The node:latest does not have the appropriate system dependencies to run the browsers. You can use the Playwright docker image. ui-test: ...
Read more >Troubleshoot your Playwright tests and find the root cause for ...
Overview of the Open Source Root Cause project which makes it easy to find the reason for failing Playwright or Puppeteer tests.
Read more >WebSocket Security - Heroku Dev Center
The WebSocket protocol is a young technology, and brings with it some risks ... Always process messages received on the client side as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@cuongld2 That’s probably because Jest does not exit fast enough for the websocket error to be thrown. Most likely Jest will wait for the open socket connection to close before exiting, but Playwright won’t do that. I’d recommend to await things, for example:
Thank you guys, Works like a charm.