[BUG] 1 error was not a part of any test, see above for details
System info
- Playwright Version: [v1.41]
- Operating System: [Windows 10, javascript, ]
- Browser: [Chromium]
- Other info: VS Code Plugin v1.0.21
Source code
[We will only be able to work on the issues that we can reproduce.]
[Please provide a self-contained example in a form of a snippet, archive or a repository.]
test("Test multiple responses...", async ({ page, request }, testinfo) => { let bibleResponses = new Array();
await page.route(/.+\/ReadAllVersesInChapter.*/i, async route =>
{
const response = await route.fetch();
const json = await response.json();
json.push({ name: 'Playwright', id: 100 });
bibleResponses.push(json);
await route.fulfill({ response, json });
});
await page.goto( ask in in a private e-mail, don't want public... );
let chapters = page.locator('#chpaters');
let numCalls = 5
for (let idx = 0; idx < numCalls; idx++)
{
console.log(`Getting request ${idx+1} of numCalls ${numCalls}`);
await chapters.selectOption(`${idx+1}`);
}
// Interesting with the following unrouteAll() will get an error this test fails.
// Without the page.unrouteAll will get the 1 test passage but the error mentioned in the title...
await page.unrouteAll()
console.log(`there are ${bibleResponses.length} responses...`);
})
[Repro scenario can't be large or have external dependencies.]
Steps
- Run the test seems the call to unrouteAll() be it in my code or PW's tear down. Now we have an error...
Expected Test completes with no errors.
Actual Depending if i have a call to page.unrouteAll() will differ but still an error. With a page.unrouteAll() my test variation will fail, and within the debugger will appear the exception is pointing to the line:
const response = await route.fetch(); // within the page.route()...
Without the unrouteAll() will get:
1 test pass 1 error was not a part of any test... Sure seems there is an issue associated with the unrouteAll() be it in my test code or PW's cleanup code...
This looks like it is working as intended. Your route will fail if the test ends mid-route. What error does it give you if you call unrouteAll? Is it a real error? If it is, looks like it is working as intended.
Thanks Pavel, the error/behavior depends with or without the page.unrouteAll()..
Without the unroute. My test passed but get the mysterious "1 error but not part of any test..."
With the unrouteAll() will see my last message being reported
there are 1 responses...
So that is the last line of my test, followed immediately with an exception and the execution in the page.route() sitting on the fetch() reporting fetch is not registered.
Also to be clear the error is reported after the function exists my test code, and the order of execution is unrouteAll() i print how many responses received, function exists with a debugger the error is caught within the page.route(), absolutely no way this is expected behavior... If you look int discord for the issue with same title, feel free to send a private e-mail, will share the url and should be a 100% working repro.
Could you share the output, it is a little hard to navigate via the description?
Okay check the image. Only line of code i changed between the two is the commented unrouteAll().. And if you check the output... The response count on the left is 5, as i'd expect it to correctly be. On the right it is 6...
We can't reproduce this locally, being able to reproduce this would make this issue actionable.
So what version are you on? Strange as this is pretty much 100% stock. Even better, creating an entirely new project....
Repro. Start VS Code Command Palette: Playwright Install Paste in the function Run test.... SPLAT ERROR as reported.
Not sure. I should have the latest public PW build? I created a new folder just now and installed should be stock and up to date... All my other PW test suites appear to be running fine. Seems related to the page.route and tearing down the registration. If in the test the error fetch unregistered, if no unrouteAll() caught by a generic catch handler thus "An error not part of a test..."
Would add my box is pretty much a fresh/clean install of Win 10, and install very few other programs than what i absolutely must. I.E. VS, VS Code and a few other dev related programs.
Another thought how were you able to run the repro as-is without the IP?
That's the thing, I could not repro. Need something I can repro with, self-contained, minimal.
But you didn't run the code provided, nor asked for the web address, i don't want that public.
If URL is not public, I won't be able to access it. It is always best to reduce the failure to a minimal self-contained repro that we can run locally. That way we can act on the issue.
It is public, i don't the ip shown...
In this case I would encourage you to provide a minimal repro.
How much more minimal can it be? 19 lines?
Anything self-contained that I can run locally.
Closing as non-actionable due to no repro. Please file a new issue if you find a way to reproduce it for us.
This will raise the error and have other issues.
test('test', async ({ page }) => { let cnt = 0; try { await page.route(/.+.*/i, async route => { cnt++; const response = await route.fetch(); let payload = await response.text(); await route.fulfill({ response, payload }); });
await page.goto('https://www.amazon.com/');
console.log(`there ere ${cnt} requets...`);
}
catch (err)
{
console.log(Error: ${err});
}
});