New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConsoleMessageCollection doesn't collect all console messages #795
Comments
uhm, this works on my machine: def test_repl_error_ouput_console(self):
self.pyscript_run(
"""
<py-repl id="my-repl" auto-generate="true"> </py-repl>
"""
)
self.page.locator("py-repl").type("this is an error")
self.page.locator("button").click()
expected_message = """\
[pyscript/base] PythonError: Traceback (most recent call last):
File "/lib/python3.10/asyncio/futures.py", line 201, in result
raise self._exception
File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
result = coro.send(None)
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 506, in eval_code_async
await CodeRunner(
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 241, in __init__
self.ast = next(self._gen)
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 142, in _parse_and_compile_gen
mod = compile(source, filename, mode, flags | ast.PyCF_ONLY_AST)
File "<exec>", line 1
this is an error
^^^^^
SyntaxError: invalid syntax
"""
assert self.console.all.lines[-1] == expected_message
assert self.console.error.lines[-1] == expected_message
for line in self.console.all.lines:
print('🔥', line) And the error message is correctly printed. So, can you:
|
Thanks for the review. |
@antocuni just so we don't loose track of it (maybe you prefer a new issue?) |
@marimeireles PR #874 should fix it |
…#874) Until now, we didn't have a nice way to check that we expect a specific JS error in the web page. This PR improves check_js_errors() so that now you can pass a list of error messages that you expect. It is tricky because we need to handle (and test!) all various combinations of cases: - errors expected and found / expected but not found - unexpected errors found / not found Moreover, JS exceptions now are logged in the special category console.js_error, which means that the printed text is also available using e.g. self.console.js_error.text or self.console.all.text. However, this should never be required and it's preferred to use self.check_js_errors to check for exceptions. This fixes #795 . Finally, use the new logic to improve test_no_implicit_target.
Checklist
What happened?
We have a helper object to collect console messages:
pyscript/pyscriptjs/tests/integration/support.py
Lines 274 to 339 in b674515
I can't figure out why but this class doesn't collect all messages. Here's an example:
I'm trying to throw an error while using the REPL and catch the console output. Here's the code that I'm using to achieve that:
This will produce the following output:
As you can see the last console.error is not being caught by the
ConsoleMessageCollection
class... I wonder if it's some async method behind it because it's not printed sequentially (in between the sun emojis)...Should we just add this method?
page.on("console", ...)
into our object and try to incorporate this there?Or any idea on what's happening here? @antocuni
What browsers are you seeing the problem on? (if applicable)
No response
Console info
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: