How can I make my tests more readable?

// We use nested describe blocks to make the intent of each test clearer

describe('the Array object', () => {

  describe('the push method', () => {
    it('should add pushed item onto array', () => {
      const array = []
      array.push(1)
      expect(array).toEqual([1])
    })
  })

  describe('the pop method', () => {
    it('should remove the last item from the array', () => {
      const array = [1, 2, 3]
      array.pop()
      expect(array).toEqual([1, 2])
    })
  })

})

Last updated

Was this helpful?