re: 1. let, const and ... var VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Could you please explain why you use only var with jest?
 

Oh, no. I only ever use var in this scenario. Lets me skip out of the block scope without a separate variable declaration. And if no error happens, the variable is just undefined.

Aha :)
So here is a place where var is still useful 😉

@adrianhelvik
Did you mean:

let error
try {
  await foo()
} catch (e) {
  error = e
}
expect(error.message).toMatch('foo') // you can use string literals if you don't have a complex RegEx
code of conduct - report abuse