testcafe: Safari: Uncaught object "[object Object]" was thrown. Throw Error instead.
What is your Test Scenario?
This error occurs on a number of tests… but the easiest one is navigating to a url that redirects.
What is the Current behavior?
Similar to #6593, I’m getting an uncaught object error in Safari. I’m suppressing JS errors and uncaught errors… but my tests are still failing.
What is the Expected behavior?
I can navigate to the desired page, and no error is thrown once the page loads
What is your web application and your TestCafe test code?
Your website URL (or attach your complete example):
Your complete test code (or attach your test files):
import { Selector } from 'testcafe';
fixture('Navigate to petition page, non-promoteable petition').page('https://www.change.org/');
test('Ensure promotion page does not show', async t => {
await t
.navigateTo('/p/united-nations-send-matt-damon-to-mars-to-retrieve-opportunity/sponsors/new')
.expect(Selector('[data-testid="signform-submit-button"]').visible)
.ok();
});
Your complete configuration file (if any):
{
"src": "./tests/**/*.js",
"clientScripts":[
{
"module":"axe-core/axe.min.js"
}
],
"assertionTimeout": 15000,
"ajaxRequestTimeout": 40000,
"pageLoadTimeout": 30000,
"selectorTimeout": 15000,
"disableMultipleWindows": false,
"quarantineMode": false,
"skipJsErrors": true,
"disablePageCaching": true,
"reporter": [
{
"name": "xunit",
"output": "artifacts/test-results/results.xml"
},
{
"name": "spec"
}
],
"screenshots": {
"fullPage": true,
"takeOnFails": true,
"pathPattern": "${TEST_ID}/${RUN_ID}_${FILE_INDEX}.png",
"path": "artifacts/screenshots",
"thumbnails": false
}
}
Your complete test report:
1) Uncaught object "[object Object]" was thrown. Throw Error instead.
Browser: Safari 15.0 / macOS 10.15.7
Screenshot: /Users/rcooper/work/github.com/change/regression-qaa/artifacts/screenshots/test-1/_errors/1.png
Screenshots:
https://user-images.githubusercontent.com/37812673/137813141-419be9a1-af3c-4f8e-8bfa-0b7be28b96e8.png
Steps to Reproduce:
- Go to my website …
- Execute this command…
- See the error…
Your Environment details:
- testcafe version:
1.16.1
- node.js version:
14.16.1
- command-line arguments:
testcafe safari -u
- browser name and version:
Safari 15.0
- platform and version:
macOS 10.15.7
- other:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Address #6624, adding new keyword to page-unload-barrier Promise — committed to rob4629/testcafe by rob4629 3 years ago
- fix: address #6624, adding new keyword to page-unload-barrier Promise (#6719) — committed to DevExpress/testcafe by rob4629 3 years ago
@danieltroger
Hello,
Thank you for your research, we’ll review @rob4629’s PR.
I tried to prepare a pull request but I’m failing at creating a test case because it’s impossible to install IE11 and I’m running macOS:
Error: Cannot find the browser. "ie" is neither a known browser alias, nor a path to an executable file.
But I made a patch instead that you can use to fix the error locally while we’re waiting for testcafe @rob4629:
testcafe_fix_6624.patch.zip
Put this into your
package.json
:unzip the file and put it into a folder called
patches
relative to your package.json and runyarn install
You might have to replacelatest
in the resolution with whatever version you have pinned oftestcafe
.Generated with https://yarnpkg.com/cli/patch and works with yarn 3.1.0
Hey,
It’s 10pm and I’m still at work because I debugged, I think, this issue. Sorry for this message being bad and stuff I just want to go home.
I’m getting this error in safari:
I think it is the same issue?
I tracked it down during the last 3 hours:
The service worker on the site sends a payload to the “backend” looking like this
with
executionError
being an empty object (it’s supposed to be null), that makes the backend throw an error.In the backend, it has a very misleading stack trace pointing essentially to the test code file itself, but that’s this one with the head cut off (I think):
This is because at this place the current place in the code is used if no callstack is recieved from the frontend:
On the frontend, the message containing the
executionError
empty object is passed to the service worker by some code readingsessionStorage
.On the page load before the load where that is sent, an exception is thrown and written to the sessionStorage. However, it is not properly serialized - only by
JSON.parse
, which just turns it into an empty object.Proof:
The actual error has the following
.stack
property:Reading that stack trace, the error is thrown here:
And originates from here (the call to
Nt
):Which is this part in the original, unminfied code (
Promise$3
):This shows us that it’s probably a minification error. Something has stripped the
new
keyword, making the call to thePromise
constructor fail. It’s either a bug in the minifier that was used or a configuration mistake.@Farfurix I would be grateful if you could:
Thanks ❤️
@rob4629
Hello,
I reproduced this issue. We will update this thread once we have any news.