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 on
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 on

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


```
#Your awesome code
```