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

Allow throwing things other than errors within withBrowser #146

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

calebeby
Copy link
Member

@calebeby calebeby commented Jul 8, 2021

This is a super minor thing but sometimes for debugging I use the trick shown here (throw new Error('leave the browser open')) to leave the headed browser open even if the test passes. This is fine, but sometimes I want to type less, so I do throw 0 which should have the same effect (makes the test fail so the browser says open). But there is a bug where Pleasantest expects anything thrown from the test to be an Error. This PR fixes that bug.

Copy link
Member

@Paul-Hebert Paul-Hebert left a comment

Choose a reason for hiding this comment

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

Looks good!

A couple non-blocking thoughts:

  1. Would it be helpful to update the README to suggest throw 0 since that's so concise?
  2. Is this a common enough pain point that it would make sense to add a more formal way to do this? Like a leaveOpen() method or something?

@calebeby
Copy link
Member Author

calebeby commented Jul 12, 2021

Is this a common enough pain point that it would make sense to add a more formal way to do this? Like a leaveOpen() method or something?

There used to be a debug() method, but I didn't like it because it had to be added to the destructured parameter list (which VSCode won't add automatically like it does for imports), and then it had to be removed from the parameter list once you were done. I think I like relying on something that can be written without any imports/destructurings.

I think at one point there was a modifier like withBrowser.headed.leaveOpen(() => {}) or something that I experimented with. What do you think of that?

@calebeby calebeby merged commit 8619f64 into main Jul 12, 2021
@calebeby calebeby deleted the throw-non-error branch July 12, 2021 15:47
@github-actions github-actions bot mentioned this pull request Jul 12, 2021
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