Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

jest test async code

### Notes

- Add [TODO: Code shorthand span ] to the function that gets passed to the test - Use [TODO: Code shorthand span ] when calling the function under test - Make the function under test ` async ` - Add [TODO: Code shorthand span ] as necessary in the function under test

### Test file

javascript
const sum = require('./sum')

test('adds 1 + 2 to equal 3', async () => {
  const result = await sum(1, 2)
  expect(result).toBe(3)
})

### File under test

javascript
async function sum(a, b) {
  // do some 'await' stuff here
  return a + b
}

module.exports = sum