mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 19:25:35 -05:00
Introduce/improve check_js_errors and improve test_no_implicit_target (#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.
This commit is contained in:
@@ -165,7 +165,15 @@ function parseConfig(configText: string, configType = "toml") {
|
||||
catch (err) {
|
||||
const errMessage: string = err.toString();
|
||||
showError(`<p>config supplied: ${configText} is an invalid TOML and cannot be parsed: ${errMessage}</p>`);
|
||||
throw err;
|
||||
// we cannot easily just "throw err" here, because for some reason
|
||||
// playwright gets confused by it and cannot print it
|
||||
// correctly. It is just displayed as an empty error.
|
||||
// If you print err in JS, you get something like this:
|
||||
// n {message: '...', offset: 19, line: 2, column: 19}
|
||||
// I think that 'n' is the minified name?
|
||||
// The workaround is to re-wrap the message into SyntaxError(), so that
|
||||
// it's correctly handled by playwright.
|
||||
throw SyntaxError(errMessage);
|
||||
}
|
||||
}
|
||||
else if (configType === "json") {
|
||||
|
||||
Reference in New Issue
Block a user