Skip to content
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

fix(eval): be able to throw protocol like errors #4551

Merged
merged 3 commits into from Jun 11, 2019

Conversation

JoelEinbinder
Copy link
Collaborator

sorry

@@ -182,6 +182,12 @@ module.exports.addTests = function({testRunner, expect}) {
});
expect(result).toBe(undefined);
});
it('should be able to throw a tricky error', async({page}) => {
const error = await page.evaluate(() => {
throw new Error('Object reference chain is too long');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the error text dynamically - this way it'll be a cross-browser test.

    it('should be able to throw a tricky error', async({page, server}) => {
      const windowHandle = await page.evaluateHandle(() => window);
      const errorText = await windowHandle.jsonValue().catch(e => e.message);
      const error = await page.evaluate(errorText => {
        throw new Error(errorText);
      }, errorText).catch(e => e);
      expect(error.message).toBe(errorText);
    });

@aslushnikov
Copy link
Contributor

Interestingly enough, this test won't work in Firefox 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants