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

pass parameter to throw #180

Open
thsmale opened this issue Jan 28, 2023 · 0 comments
Open

pass parameter to throw #180

thsmale opened this issue Jan 28, 2023 · 0 comments
Labels
feature New functionality or improvement

Comments

@thsmale
Copy link

thsmale commented Jan 28, 2023

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: > 18.13.0
  • module version: ^9.02
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi
  • any other relevant information:

What problem are you trying to solve?

I am testing a function that requires me to pass a parameter to it. In certain cases it will throw an Error. I am unable to test this function without making a wrapper for it.

const foo = (message) => {
  throw Error(message)
}

let msg = "sup hapi devs" 
expect(foo(msg)).to.throw(msg) // Epic fail

const wrapper = () => foo(msg)
expect(wrapper).to.throw(msg) // Success! 

Do you have a new or modified API suggestion to solve the problem?

I'll look into it, just wanted to see if this concern is legitimate.

@thsmale thsmale added the feature New functionality or improvement label Jan 28, 2023
@thsmale thsmale changed the title pass Parameter to throw pass parameter to throw Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

1 participant