DEV Community

Discussion on: Why isn't this unit test catching an error from this async/await function?

Collapse
 
christianschulze profile image
Christian Schulze • Edited
const fetchItem = async function (itemName) {
  if (typeof itemName !== 'string') {
    return Promise.reject(new Error('argument should be a string'))
  }  else {
    return await db.select(itemName)
  }
}
Collapse
 
entrptaher profile image
Md Abu Taher • Edited

Hello, you should use three backticks to nicely format this piece of code. :) It will look cleaner. Look at following example.


```
#Your awesome code
```